我正在使用Yii 1.1.16,在我的CGridView中,我正在添加自定义过滤器下拉列表。但是在下拉列表中设置了值,但不是文本。知道为什么吗?
这是html
<select name="Comments[make]">
<option value=""></option>
<option value="02"></option>
<option value="33"></option>
<option value="31"></option>
</select>
在我的CGridView中我有这个
array(
'name'=>'make',
'filter'=>array_map("strtoupper", CHtml::listData(Posts::model()->with('abc')->findAll(array('group'=> 'abc.make')), 'id', 'abc.make')),
'value'=>'strtoupper($data->_abc->make)',
),
在我的Posts.php
模型中我有这个
/**
* @return array relational rules.
*/
public function relations()
{
'abc' => array(self::HAS_MANY, "Abc", array("make_code" => "make_code", "model_code"=>"model_code")),
);
}
答案 0 :(得分:0)
试试这个; -
在ListData中
CHtml::listData(Posts::model()->with('abc')->
findAll(array('condition'=>'group="abc.make"')),
'id', 'abc.make')
答案 1 :(得分:0)
试试这个
'filter'=>array_map( CHtml::listData(Posts::model()->with('abc')->
findAll(array('group'=> 'abc.make')), 'id', 'abc.make')),