【发布时间】:2013-12-06 21:36:05
【问题描述】:
我无法按网格中的相关对象进行过滤。
我有以下两种型号:
Model Foo:
id
name
create_date
Model Boss:
id
foo_id (FK to Foo Model)
create_date
现在,我以这种方式列出我所有的 Boss 对象:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'boss-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'ID',
array(
'header'=>'Foo', //the header cell text.
'name' => 'foo.name', //the attribute name of the data model.
'value' => '$data->foo->Name',
'filter' => CHtml::activeTextField(Foo::model(),'Name'),
),
'CREATE_DATE',
),
)); ?>
问题在于 FK 是数字,但表示(标签)是文本。所以我需要知道如何将此对象转换为网格中的过滤器。
【问题讨论】: