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')),
),
...
),
...
));[...]