As I haven’t received any replies I kept digging and sort of solved the problem, but not in an elegant way IMHO.
What I wanted in vehicle’s view.php
<?php $this->widget('bootstrap.widgets.TbDetailView',array(
'data'=>$model,
'type'=>'striped bordered condensed',
'attributes'=>array(
'id',
'vin',
'vehmake.name',
'vehmodel.name',
'vehtrim.description',
'license_tag',
...
where ‘vehtrim’ is a parent, ‘vehmodel’ is a grandparent and ‘vehmake’ is a great-grandparent of ‘vehicle’. I though I could access the last two directly by defining a relations() using ‘through’, but it appears that ‘through’ only works forward (HAS_ONE/HAS_MANY instead of BELONGS_TO).
What I ended up doing in the vehicle’s view.php:
<?php $this->widget('bootstrap.widgets.TbDetailView',array(
'data'=>$model,
'type'=>'striped bordered condensed',
'attributes'=>array(
'id',
'vin',
array(
'label' => 'Make',
'value' => $model->VehicleMake,
),
array(
'label' => 'Model',
'value' => $model->VehicleModel,
),
'vehtrim.description',
'license_tag',
...
which required changes to the vehicle model:
...
/**
* Gets this vehicle's make
* @return string vehicle make.
*/
public function getVehicleMake()
{
return TVehmake::model()->findByPk(TVehmodel::model()->findByPk(TVehtrim::model()->findByPk($this->vehtrim_id)->vehmodel_id)->vehmake_id)->name;
}
/**
* Gets this vehicle's model
* @return string vehicle model.
*/
public function getVehicleModel()
{
return TVehmodel::model()->findByPk(TVehtrim::model()->findByPk($this->vehtrim_id)->vehmodel_id)->name;
}
Is there a better way? Suggestions are appreciated.
Thanks,