title: Yii same model saved twice, AJAX Validation
body: <p>I need to save model twice with different data:</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code> $modelClient = new Client;
  
   if(Yii::app()-&gt;getRequest()-&gt;getIsAjaxRequest()) {
      echo CActiveForm::validateTabular( array( $modelClient));
      Yii::app()-&gt;end();
   }
  </code></pre>
  
  <p><strong>View (only relevant part of it)</strong></p>
  
  <pre><code>&lt;?php echo $form-&gt;textFieldRow($modelClient, '[0]name'); ?&gt;
  &lt;?php echo $form-&gt;textFieldRow($modelClient, '[0]street'); ?&gt;
  
  &lt;?php echo $form-&gt;textFieldRow($modelClient, '[1]name'); ?&gt;
  &lt;?php echo $form-&gt;textFieldRow($modelClient, '[1]street'); ?&gt;
  </code></pre>
  
  <p><strong>JSON OUTPUT</strong></p>
  
  <pre><code>{"Client_0_name":["field is empty"],"Client_0_street":["field is empty"]}
  </code></pre>
  
  <p>So the second model is just ignored. </p>
  
  <p><strong>I tried</strong> </p>
  
  <pre><code>if(Yii::app()-&gt;getRequest()-&gt;getIsAjaxRequest()) {
     foreach ($_POST[Client] as $client) {
      $temp = new Client;
      $temp-&gt;setAttributes($client);
      echo CActiveForm::validate( array( $modelClient));
     }
     Yii::app()-&gt;end();
  }
  </code></pre>
  
  <p>but it returns JSON Output without the right id, eg.:</p>
  
  <pre><code> {"Client_name":["field is empty"],"Client_street":["field is empty"]}
  </code></pre>
  
  <p>and as a result it just doesnt validate any of fields.</p>