Skip to content

Instantly share code, notes, and snippets.

@cebe
Last active December 17, 2015 02:28
Show Gist options
  • Save cebe/5535668 to your computer and use it in GitHub Desktop.
Save cebe/5535668 to your computer and use it in GitHub Desktop.
CGridView related objects column.
<?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