Hi Seenivasan!
Hope all is well in that part of the world.
My model has a standard search and a modified version to include a ManyMany relation to categories (which creates its own problems in the AR and CGridView with paging due to duplicates.
public function searchSites() {
$criteria = new CDbCriteria;
$criteria->with = array('SiteCategories');
$criteria->compare('SiteCategories.category_id', $this->category_id);
$criteria->compare('id', $this->id, true);
$criteria->compare('active', $this->active)
$criteria->compare('status_id', $this->status_id);
$criteria->compare('quality_id', $this->quality_id);
$criteria->compare('comscore', $this->comscore);
$criteria->together = true;
return new CActiveDataProvider(get_class($this), array(
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize',User::model()->myAccount()->find()->pagesize),
),
'criteria' => $criteria,
));
}
Rules for Site look like
public function rules() {
return array(
array('publisher_id, site_name, site_url, category_id', 'required'),
array('leadowner_id, network_coord_id, active, status_id, quality_id, problem', 'default', 'setOnEmpty' => true, 'value' => null),
array('active, display_live, mobile_live, video_live, mobile_enabled, problem, premium_site, remnant_site', 'numerical', 'integerOnly' => true),
array('publisher_id, leadowner_id, network_coord_id, category_id, appnexus_id, comscore', 'length', 'max' => 11),
array('site_name, site_url', 'length', 'max' => 100),
array('status_id', 'length', 'max' => 20),
array('quality_id, premium_type, remnant_type', 'length', 'max' => 2),
array('registered_date, signed_date, live_date, sentto_network_date', 'safe'),
array('id, publisher_id, site_name, site_url, leadowner_id, network_coord_id, rev_share_pct, asked_cpm, floor_cpm, active, status_id, quality_id, category_id, audit_status, problem', 'safe', 'on' => 'search'),
);