hello,
i have a model called "boUserGrants" used to relate a user to a dealer. so, in its model file, i have:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'idUser0' => array(self::BELONGS_TO, 'User', 'id'),
'idDealer0' => array(self::BELONGS_TO, 'Dddealers', 'idDealer'),
);
}
Now, in the admin view i don’t want to see only ids, of course. I’d like to see usernames and dealer names. In the views/boUSerGrants/admin.php file i wrote:
<?php $this->widget('zii.widgets.grid.CGridView', array( 'cssFile'=>'css/gridview.css',
'id'=>'bo-user-grants-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'idDealer',
array(
'value'=>'User::model()->find("id=$data->idUser")->firstLastName',
'header'=>'User',
),
'boGrant',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
This way i correctly see user’s first and last name in stead of ID. that’s great. What is missing is the filter input under the header column. I tried to add it by writing:
array(
'value'=>'User::model()->find("id=$data->idUser")->firstLastName',
'header'=>'User',
'filter'=>'<input type="text" name="BoUserGrants[idUser]">',
),
but, well… doesn’t work. The coolest thing would be to have a select in which i could see all of the users…
how could i do?
thanks