I've just spent a few hours trying to figure this out, turns out you can nest relational criteria in the search() function in a model.
Like this:
Both 'event' and 'student_user' are BELONGS_TO relations. 'student_username' is a public variable defined at the beginning of my model (and set as safe in my rules). I've been trying use the following in my CGridView widget columns:
The nested criteria helped me get the search function working, hope this helps someone
jc
Like this:
$criteria->with = array('event' => array('with' => 'student_user'));
$criteria->compare("student_user.username", $this->student_username, true);Both 'event' and 'student_user' are BELONGS_TO relations. 'student_username' is a public variable defined at the beginning of my model (and set as safe in my rules). I've been trying use the following in my CGridView widget columns:
array(
'name' => 'student_username',
'header' => 'Student',
'type' => 'raw',
'value' => '$data->event->student_user->username'
),The nested criteria helped me get the search function working, hope this helps someone
jc