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:
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,
));
}
I’m newbie here, so forgive me if question is silly… I did as it is written above however I cannot sort or search by this column (field from foreign table). How can I do this?
// Preparing the DataProvider in the model:
return new CActiveDataProvider(get_class($this),array(
'sort'=>array(
'multiSort'=>false,
'attributes'=>array(
'Customer'=>array(
'asc'=>'customer.shortname',
'desc'=>'customer.shortname desc',
),