Revision #4 has been created by rafaelt88 on Jun 30, 2015, 9:09:23 PM with the memo:
View a related field in CGridView
« previous (#3)
Changes
Title
unchanged
View a related field in CGridView
Category
unchanged
Tips
Yii version
unchanged
Tags
unchanged
CGridView, Relation Field
Content
changed
[...]
2) First, it is necessary to specify that the model will use the relationship defined above; Then, the comparison between the related field and a variable is defined; Finally, specify what will be the order for the field shown in CGriView.
~~~~
class TableB extends ActiveRecord {
...
public function search() {
$criteria = new CDbCriteria();
$criteria->with = array('tableA');
...[...]
array(
'name' => 'tableA.name',
'value' => '$data->tableA->name)',
'filter' => CHtml::textField('tableA_name', Yii::app()->request->getParam('tableA_name')),
),
...
),
...
));[...]