문제

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',
    ),
도움이 되었습니까?

해결책

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',
),
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top