Model:數組
1. 添加filter用的屬性
var $a = 「」;
var $b = 「」;ide
2. 修改rules方法中的配置
array(‘……., a, b’, ‘safe’, ‘on’=>’search’);學習
3. 注意relations方法
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
‘xxx‘ => array(self::HAS_ONE, ‘xxxModel’, array(‘…’ => ‘….’)),
);
}this
4. 修改search()方法添加行
$criteria->compare(‘xxx.ax‘,$this->a);
$criteria->compare(‘xxx.bx‘,$this->b);spa
View
1. ‘dataProvider’=>$model->with(「xxx「)->search(),orm
2. 列展現修改
array(
‘name’ => ‘a‘,
‘value’ => ‘$data->xxx->ax‘,
‘filter’ => array(select的下來菜單數組),
),
array(
‘name’ => ‘b‘,
‘value’ => ‘$data->xxx->bx‘,
‘filter’ => array(1 => 「Set」, 0 => ‘Not Set’),
),ci
代碼提示:
1. 添加的兩個屬性僅僅用於記錄頁面的搜索條件
2. search方法中的CDbCriteria搜索方法沒有任何變化,請學習如何使用關聯搜索it