title: ajax validation for multiple instance of model in Yii
body: <p>I have two models namely acl and user. Each have there own set of validation rules. I however use all input fields within one form. </p>
  
  <p>In the UserController I have two ajax validation methods within the createAction method</p>
  
  <p>This looks like this</p>
  
  <pre><code> public function actionCreate()
      {
              $model=new user;
              $acl = new acl;
  
  
              // Uncomment the following line if AJAX validation is needed
  
                      $this-&gt;performAjaxValidation1($acl);
  
                      $this-&gt;performAjaxValidation($model);
  
  
  
              //$this-&gt;performAjaxValidation1($acl);
  
              //$valid=$model-&gt;validate();
              //$valid=$acl-&gt;validate() &amp;&amp; $valid;
  
  
  
              if(isset($_POST['user'], $_POST['acl']))
              {
                      $model-&gt;attributes=$_POST['user'];
                      $acl-&gt;attributes=$_POST['acl'];
                      if($model-&gt;save() &amp;&amp; $acl-&gt;save())
                              $this-&gt;redirect(array('view','id'=&gt;$model-&gt;id));
              }
  
              $this-&gt;render('create',array(
                      'model'=&gt;$model,
                      'acl'=&gt;$acl
              ));
      }
  </code></pre>
  
  <p>AjaxValidation</p>
  
  <pre><code> protected function performAjaxValidation($model)
      {
              if(isset($_POST['ajax']) &amp;&amp; $_POST['ajax']==='user-form')
              {
                      echo CActiveForm::validate($model);
                      Yii::app()-&gt;end();
              }
      }
  
      /**
       * Performs the AJAX validation.
       * @param CModel the model to be validated
       */
      protected function performAjaxValidation1($acl)
      {
              if(isset($_POST['ajax']) &amp;&amp; $_POST['ajax']==='user-form')
              {
                      echo CActiveForm::validate($acl);
                      Yii::app()-&gt;end();
              }
      }
  </code></pre>
  
  <p>Only one form is validating 
  can anyone sugges</p>