I know this topic has been done to death, but all the searching and hacking away I do just leaves me more confused than ever. Is there a definitive guide to properly including a relation in a CGridView, and actually having both the filter (text field, NOT drop down list) AND sorting work properly?
Here is what I am trying, based on this topic:
/********************/
/* Highlights model */
/********************/
public $fullname;
//relation
'user' => array(self::BELONGS_TO,'UserInfo','username'),
//search() method
$criteria->compare('fullname',$this->fullname,true); //also tried $this->user->fullname
$criteria->with=array('user'); //tried with and without this line
/**************************/
/* CGridView (index view) */
/**************************/
array(
'name' => 'user', //also tried username and fullname
'filter' => CHtml::activeTextField($model, 'fullname'),
'value' => '$data->user->fullname',
),
No combination of any of these lines seems to work - the sorting is disabled and the filter does nothing when I type anything into it; no errors, no nothing. I always get tripped up by this issue. There must be a straightforward method to getting this to work…does anyone know how???