Hello everyone.
I want to display and manage the items that belong to a different model.
In my controller I have this code to create a dataProvider in the parent Controller:
$vehiculo_modelos_dp = new CActiveDataProvider('vehiculo_modelo', array(
'criteria'=>array(
'condition'=>'vehiculo_marca_id=:vehiculo_marca_id',
'params'=>array(':vehiculo_marca_id'=>$model->id),
'order'=>'t.orden, vehiculo_modelo asc',
'with'=>'vehiculo_tipo',
'together'=>true,
),
));
This goes in the _form partial of the parent Controller:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$vehiculo_modelos_dp,
'columns'=>array(
'id',
'vehiculo_modelo',
array(
'name' => 'Tipo',
'value' => '$data->vehiculo_tipo->vehiculo_tipo',
'sortable'=>true,
),
'orden',
'activo',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
The grid shows up alright, but I can’t sort it (nothing happens when I click the header) and the links of the action buttons (delete, edit, view) act on the parent model, not the child.
Also, my column named "Tipo" is not sortable (there is no link to click).
Can you help me work this out please?