Well i got table Quiz and User. I want to display the related columns from table User in CGridView.
First in controller to get relational query
$dataProvider=new CActiveDataProvider('Quiz', array(
'criteria' => array(
'with' => 'user' // relational query name
)
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
In view
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns' => array(
'name',
'description',
array( // Problem is here how i display the username column from table User ?
'name'=>'username',
'value'=>$data->User->username,
),
'added',
array( // display a column with "view", "update" and "delete" buttons
'class'=>'CButtonColumn',
),
)
));
?>
Really fast replay on IRC channel, ty. For solution you have to replace the array part with ‘relation.column’