Before asking this question I want to tell that I had asked this question in stackoverflow.com but not got any results so I am asking here.In Yii I am doing multimodel.My database is something like this
+++++ Group ++++++
id
name
+++++ Member ++++++
id
group_id
firstname
lastname
membersince
In Group controller I want to show Member’s attributes.Everything is working fine but when I am using manage option from the menu it is showing the attributes for both models but in two different grid-view.I want to show both models attributes in a single grid-view. The code for Member controller is like this
public function actionAdmin()
{
$model=new Group('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Group']))
{
$model->attributes=$_GET['Group'];
}
$member=new Member('search');
$member->unsetAttributes(); // clear any default values
if(isset($_GET['Member']))
{
$model->attributes=$_GET['Member'];
}
$this->render('admin',array(
'model'=>$model,
'member'=>$member,
));
}
for View in Group admin code is like this
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'member-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'name',
array(
'class'=>'CButtonColumn',
),
),
));
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'member-grid',
'dataProvider'=>$member->search(),
'filter'=>$member,
'columns'=>array(
'firstname',
'lastname',
array(
'class'=>'CButtonColumn',
),
),
));
Here I have used CGridView for two times to show models for both attributes. So can someone tell me how to show models in a single CGridView.Any help and suggestions will be highly appriciable.