title: YII Inserting Multiple Dynamic rows
body: <p>This is my code in view/_form.php</p>
  
  <pre><code>&lt;tr&gt;
    &lt;td&gt;
      &lt;?php
      $criteria = new CDbCriteria;
      $criteria-&gt;order = 'ScriptArgumentClassType'; //or whatever field
      echo CHtml::activeDropDownList($meta,**'[]ScriptArgumentClass_id'**,CHtml::listData(AutoScriptArgumentClass::model()-&gt;findAll`enter code here`($criteria),'id','ScriptArgumentClassType'), array('prompt'=&gt;'Please select Argument class type'));
      ?&gt;  
    &lt;/td&gt;
    &lt;td&gt;
      &lt;?php
      $criteria = new CDbCriteria;
      $criteria-&gt;order = 'TnType'; //or whatever field
      echo CHtml::activeDropDownList($meta,**'[]Type_id'**,CHtml::listData(AutoTnType::model()-&gt;findAll($criteria),'id','TnType'), array('prompt'=&gt;'Please select TN type'));
      ?&gt;
    &lt;/td&gt;
  
    &lt;td&gt;
      &lt;?php
      $criteria = new CDbCriteria;
      $criteria-&gt;order = 'service'; //or whatever field
      echo CHtml::activeDropDownList($meta,'**'[]Service_id'**,CHtml::listData(Service::model()-&gt;findAll($criteria),'id','service'), array('prompt'=&gt;'Please select Service'));
      ?&gt;
    &lt;/td&gt;
  
    &lt;td&gt;
      &lt;?php
      $criteria = new CDbCriteria;
      $criteria-&gt;order = 'Manufacture'; //or whatever field
      echo CHtml::activeDropDownList($meta,'**[]Cpe_id'**,CHtml::listData(AutoCPE::model()-&gt;findAll($criteria),'id','Manufacture'), array('prompt'=&gt;'Please select CPE'));
      ?&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>this is a row of 4 columns. Actually I have used the jquery code to get rows inserted dynamically on clicking AddNew. Works Fine. Now I am trying to save it to the database using yii.   </p>
  
  <pre><code>$metadatas=$_POST['AutoTestScriptMeta'];            
  foreach ($metadatas as $metadata ) {
    $meta=new AutoTestScriptMeta;             
    $meta-&gt;attributes = $metadata;
    $meta-&gt;save(false);
  }
  </code></pre>
  
  <p>Here I am doing foreach for inserting multiple rows into one table.<br>
  It gets inserted in this way for 2 inputed row values</p>
  
  <p>1 0 0 0<br>
  0 2 0 0<br>
  0 0 3 0<br>
  0 0 0 2<br>
  1 0 0 0<br>
  0 3 0 0<br>
  0 0 4 0<br>
  0 0 0 2  </p>
  
  <p>instead of </p>
  
  <p>1 2 3 2<br>
  1 3 4 2  </p>
  
  <p>instead of inserting 2 rows it inserts 8 rows each with a column value.</p>
  
  <p>See the code in bold (** **). That is how I am declaring it as an array.</p>
  
  <p>Any help is appreciated. Please let me know if you need more details.  </p>