title: search is not working in gridview while using multiple models yii
body: <p>I am trying to access 2 related models in one CGridView interface for searching elements. But as soon as I join the second table to the first, search stops working and do not filter anything (the grid is unchanged). I have referred to many links but could not solve this problem myself.</p>
  
  <p>Tables are -
  UserMaster (user_id, name, status, ...)
  CustomerMaster (customer_id, user_id, account_number,...) </p>
  
  <pre><code>usermaster model content -
  
  public $account_number;
  public function rules()
  {
  
  return array(
          array('name', 'required'),
          array('account_number', 'safe'),
          array('user_id, name,status, account_number', 'safe', 'on'=&gt;'search'),
          );
  }
  public function relations()
  {
       return array('customer_master' =&gt; array(self::HAS_ONE, 'CustomerMaster', 'user_id'),);
  }
  public function attributeLabels()
  {
  return array(
      'user_id' =&gt; 'User',
      'name' =&gt; 'Name',
      'status' =&gt; 'Status',
      'account_number' =&gt; 'Account Number',
      );
  }
  public function search()
  {
          $criteria=new CDbCriteria;
      $criteria-&gt;alias = 't';
      $criteria-&gt;compare('t.user_id',$this-&gt;user_id);
          $criteria-&gt;compare('t.name',$this-&gt;name,true);
      $criteria-&gt;compare('t.status',$this-&gt;status);
      $criteria-&gt;with = 'customer_master';                    
      $criteria-&gt;condition = 't.user_type=2';
      $criteria-&gt;together = true;
  
      $criteria-&gt;compare('customer_master.user_id',$this-&gt;user_id,true);
      if ($this-&gt;account_number){
      $criteria-&gt;compare('customer_master.account_number',$this-&gt;account_number,true);
          }
      return new CActiveDataProvider($this, array(
              'criteria'=&gt;$criteria,
              'pagination'=&gt;array(
              'pageSize'=&gt;25),
              'sort'=&gt;array(
              'defaultOrder'=&gt;'t.user_id DESC',
              ),
          ));
  }
  
  customermaster model content-
  public function relations()
  {
      return array(
  
      'user_id' =&gt; array(self::BELONGS_TO, 'UserMaster', 'user_id'),
  
      );
  }
  
  usermaster controller code -
  public function actionAdmin()
  {
      $model=new UserMaster('search');
      $model-&gt;unsetAttributes();  // clear any default values
      if(isset($_GET['UserMaster']))
      $model-&gt;attributes=$_GET['UserMaster'];
  
      $this-&gt;render('admin',array(
              'model'=&gt;$model,
          ));
  }
  
  admin.php
  $this-&gt;widget('zii.widgets.grid.CGridView', array(
      'id'=&gt;'user-master-grid',
      'dataProvider'=&gt;$model-&gt;search(),
      //'filter'=&gt;$model,
      'columns'=&gt;array(
          array ( 
          'name' =&gt; 'customer_master.account_number',
          'header' =&gt; 'Account Number',
          'type' =&gt; 'raw',
          'value'=&gt;'$data-&gt;customer_master-&gt;account_number',
          ),
          'name',
          'status',
          array(
              'class'=&gt;'CButtonColumn',
          ),
      ),
  ));
  </code></pre>
  
  <p>By joining the above 2 models i am able to get the grid view as expected but search is not working for all the fields.</p>
  
  <p>Someone please help me in identifying the problem. I hope i have explained problem clearly.</p>
  
  <p>thanks in advance. </p>