Hi, I have this models
This is the header:
/**
* This is the model base class for the table "t_cuota_def".
* DO NOT MODIFY THIS FILE! It is automatically generated by giix.
* If any changes are necessary, you must set or override the required
* property or method in class "CuotaDef".
*
* Columns in table "t_cuota_def" available as properties of the model,
* followed by relations of table "t_cuota_def" available as properties of the model.
*
* @property string $id
* @property integer $fk_grado_id
* @property string $vigencia_desde
* @property integer $fk_cuenta_contable_id
*
* @property TGrado $fkGrado
* @property TCuotaDefDetalle[] $tCuotaDefDetalles
*/
abstract class BaseCuotaDef extends GxActiveRecord {
...
...
public function relations() {
return array(
'fkGrado' => array(self::BELONGS_TO, 'Grado', 'fk_grado_id'),
'tCuotaDefDetalles' => array(self::HAS_MANY, 'CuotaDefDetalle', 'fk_cuota_def_id'),
);
}
}
and This is the detail:
/**
* This is the model base class for the table "t_cuota_def_detalle".
* DO NOT MODIFY THIS FILE! It is automatically generated by giix.
* If any changes are necessary, you must set or override the required
* property or method in class "CuotaDefDetalle".
*
* Columns in table "t_cuota_def_detalle" available as properties of the model,
* followed by relations of table "t_cuota_def_detalle" available as properties of the model.
*
* @property string $id
* @property string $fk_cuota_def_id
* @property string $fk_concepto_cuota_id
* @property string $importe
*
* @property TCuotaDef $fkCuotaDef
* @property TCuotaConceptos $fkConceptoCuota
*/
abstract class BaseCuotaDefDetalle extends GxActiveRecord {
...
public function relations() {
return array(
'fkCuotaDef' => array(self::BELONGS_TO, 'CuotaDef', 'fk_cuota_def_id'),
'fkConceptoCuota' => array(self::BELONGS_TO, 'CuotaConceptos', 'fk_concepto_cuota_id'),
);
}
...
}
And in the view action in the header controller I want to setup the data for Header and detail:
public function actionView($id) {
//$detalle = new CuotaDefDetalle('search');
$CuotaDef = $this->loadModel($id, 'CuotaDef');
$detalle = $CuotaDef->tCuotaDefDetalles;
print_r($detalle);
$this->render('view', array(
'model' => $CuotaDef, //$this->loadModel($id, 'CuotaDef'),
'detalle'=> $detalle,
));
}
in the view I want to use CGridView widget:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'cuota-def-detalle-grid',
'dataProvider' => $detalle,
'columns' => array(
'id',
array(
'name'=>'fk_concepto_cuota_id',
//'title'=>'Concepto',
'value'=>'GxHtml::valueEx($data->fkConceptoCuota)',
),
'importe',
),
));
But I get an error that I cannot use this kind of object:
Fatal error: Call to a member function getData() on a non-object in C:\xampp\htdocs\yii\framework\zii\widgets\CBaseListView.php on line 105
I understand thet the widget needs a DataProvider object , how can I convert the line:
$detalle = $CuotaDef->tCuotaDefDetalles;
to a data provider object?
Best Regards