I have two tables.
Projects -
id
name
Gallery -
id
project_id //integer = Projects.id...foreign key in other words
photo
thumb
In my admin view of the gallery I would like instead of the project_id [which is an int] to display its respective name from table Projects. In my admin view I have:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
array(
'name'=>'name',
'value'=>'',
),
'photo',
'thumb',
array(
'class'=>'CButtonColumn',
),
),
)); ?>The name should be represented by the array column but I don't know what to put against value. Can anyone help me. I know that when I call the admin view the relations query is being executed [i can see that in the logs] and it is correct so I guessing its a matter of calling the value in the correct way.
My controller has the following admin action:
public function actionAdmin()
{
$dataProvider=new CActiveDataProvider('Gallery', array(
'criteria'=>array(
'with'=>array('project'),
),
'pagination'=>array(
'pageSize'=>self::PAGE_SIZE,
),
));
$this->render('admin',array(
'dataProvider'=>$dataProvider,
));
}project is the relation declared as:
return array(
'project'=>array(self::BELONGS_TO,'Projects', 'project_id'),
);Thanks for any help
cheers,
b

Help















