I have a CGridView widget for a Lesson model
$this->widget('zii.widgets.grid.CGridView', array( 'id'=>'lesson-grid', 'dataProvider'=>$model->search(), 'filter'=>$model,
... and Lesson is related to the User model:
'user' => array(self::BELONGS_TO, 'User', 'user_id'),
... and CGridView has a column with the username from the BELONGS_TO model described above
'columns'=>array( ... array( 'name' => 'user', 'header'=>'Teacher', 'value' => '$data->user->lastname', ),
Thus, I cannot perform a search in the CGridView in this column, but I need it.
How to search in '$ data-> user-> secondname' using CGridView?
I think I should extend the search method in the Lesson model, but how?
Now it looks like this:
public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('student',$this->student,true); $criteria->compare('comment',$this->comment,true); return new CActiveDataProvider(get_class($this), array( 'criteria'=>$criteria, )); }