Question

I am using Yii User Management along with my tables. The relation between User and Profile table is as per the extension. I am using a table called reservation which contains user_id as a foreign key reference to id field in the User table. The relation to the user table is named user.

In the admin.php of the reservation controller I want to display the First name stored in the profile table.

My query is how can I display the firstname of profiles table in gridview using $model->search() of reservation model.

Code currently being used is :

array(
    'header'=>'User',
    'name'=>'user_id',
    'value'=>'$data->user->username',
    ),
Was it helpful?

Solution

User is model is related with Profile model using the profile relations

so try this

array(
'header'=>'User',
'name'=>'user_id',
'value'=>'$data->user->profile->first_name',
),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top