Cgridview In Parentview


Yii 1.1.14

I have an employee table and a comment table

In the employee view i want to show all the comments of the employee in a grid (after the employee fields)

I tried to follow the example here

Here is where I am :

New code to defining a new search function in the model :

public $commentdate_param;

public $commentobservation_param;


public function rules()


    return array(


        array('public $commentdate_param, commentobservation_param, ...', 'safe', 'on'=>'search, searchIncludingComments'),


public function relations()


    return array(


        'employeecomments' => array(self::HAS_MANY, 'Employeecomments', 'employee_id'),



public function searchIncludingComments($parentID)


        $criteria=new CDbCriteria;


        $criteria->together = true;


        $criteria->compare('', $this->commentdate_param,true);

        $criteria->compare('employeecomments.observation', $this->commentobservation_param,true);


        $sort = new CSort;

        $sort->attributes = array(

            'commentdate_param' => array(

            'asc' => 'date_desc',

            'desc' => 'date_desc DESC',

            ), '*', /* Treat all other columns normally */



        return new CActiveDataProvider($this, array(





Adding code in the controller actionView :


$child_model = new Employee("searchIncludingComments");





    'parentID' => $id


Adding code in the view :




$this->widget('zii.widgets.grid.CGridView', array(













But I must have missed something because when it comes to grid rendering stops - but no error in log

Would be nice if somebody could help me !

I found the solution for me - all my changes and controler are worthless because now I do all stuff in the view :

    $this->widget('zii.widgets.grid.CGridView', array(


			'dataProvider'=>new CActiveDataProvider('Employeecomment',array(






					'defaultOrder'=>'date DESC',



Sure there is something I did not understand why it did not work …

"public $commentdate_param," says you have a filed called public, and $ is not allowed in rules.

BTW: This sounds like comments for a post in the Blog demo.