title: Setting array inputs rules - Yii Framework
body: <p>I'm learning yii framework for an e-commerce project and it was going great so far. I have an addition form for estates and that form is generating using database. The code below, generates the form (/views/ad/_form), and giving names to input fields like detail["ad-title"], detail["ad-image"] etc.</p>
  
  <pre><code>    &lt;?php 
      $connection = Yii::app()-&gt;db;
      $command = $connection-&gt;createCommand("SELECT * FROM eml_ozellikler");
      $options = $command-&gt;queryAll();
      $command = $connection-&gt;createCommand("SELECT * FROM eml_kurallar");
      $rules = $command-&gt;queryAll();
      $i = 0;
      foreach($options as $option){
          echo '&lt;div class="row"&gt;';
          echo $form-&gt;labelEx($model, 'detail["'.$option['name'].'"]');
          switch($option['tur']){
              case "textfield":
                  echo $form-&gt;textField($model, 'detail["'.$option['name'].'"]');
                  break;
              case "textarea":
                  echo $form-&gt;textArea($model, 'detail["'.$option['name'].'"]', array('rows'=&gt;'5','cols'=&gt;'40'));
                  break;
              case "integer":
                  echo $form-&gt;textField($model, 'detail["'.$option['name'].'"]');
                  break;
              case "selectbox":
                  CHtml::dropDownList($option['label'], 'detail["'.$option['name'].'"]', $rules[$i]['values']);
                  break;
              case "radio":
                  break;
              case "file":
                  echo $form-&gt;fileField($model, 'detail["'.$option['name'].'"]');
                  break;
              case "image":
                  break;
          }
          echo $form-&gt;error($model,'detail["'.$option['name'].'"]');
          echo '&lt;/div&gt;';
          $i++;
      }
  ?&gt;
  </code></pre>
  
  <p>The problem is when giving rules to them. Rules are working just for looking, when i add to rules this</p>
  
  <pre><code>array('detay["ad-title"]', 'required'),
  </code></pre>
  
  <p>Then, that field is being required and getting a (*). But when i submit the form, then it gives an error saying "Ad.detail["ad-title"]" value isn't defined.</p>
  
  <p>Without rules, i can post and get the posted value correctly using $_POST['Ad']['detail']["ad-title"] etc.</p>
  
  <p>Also; i checked the Yii Framework docs but couldn't find any useful thing except tabular input and Form Builder, and i couldn't implement it to my code. Because i don't want to create variables at my model, i just want to send data using just one variable and rule.</p>
  
  <p>Thanks, çağlar.</p>