Last active
December 17, 2015 02:28
-
-
Save cebe/5535668 to your computer and use it in GitHub Desktop.
CGridView related objects column.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// assuming we have a User model that has a relation to Profile model named 'profile' | |
/** @var User $user The user model */ | |
$this->widget('zii.widgets.grid.CGridView', array( | |
'id'=>'user-grid', | |
'dataProvider'=>$user->search(), | |
'filter'=>$user, | |
'columns'=>array( | |
'id', | |
'profile.name', // <-- will show the name of related profile | |
'description', | |
'created', | |
'updated', | |
array( | |
'class'=>'CButtonColumn' | |
) | |
) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment