data kota ini ada di tabel hlr_kota seperti gambar dibawah
caranya edit file Hlr.php di protected/models
ada baris ini
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(
);
}
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
tambahkan info relasi mejadi spt ini
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(
'hlr_kota'=>array(self::BELONGS_TO, 'Hlrkota', 'id_hlr_kota'),
);
}
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'hlr_kota'=>array(self::BELONGS_TO, 'Hlrkota', 'id_hlr_kota'),
);
}
lalu buka file admin.php di folder protected\views\hlr
pada baris
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'hlr-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_hlr',
//'id_hlr_op',
'id_hlr_kota',
'id'=>'hlr-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_hlr',
//'id_hlr_op',
'id_hlr_kota',
kasih komen baris id_hlr_kota dan ganti menjadi
array(
'header'=>'KOTA',
'name'=>'id_hlr_kota',
'value'=>'$data->hlr_kota->hlr_kota',
//'filter'=>hlr_kota::model()->getOption(),
),
'header'=>'KOTA',
'name'=>'id_hlr_kota',
'value'=>'$data->hlr_kota->hlr_kota',
//'filter'=>hlr_kota::model()->getOption(),
),
hasilnya spt kode dibawah
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'hlr-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_hlr',
//'id_hlr_op',
//'id_hlr_kota',
array(
'header'=>'KOTA',
'name'=>'id_hlr_kota',
'value'=>'$data->hlr_kota->hlr_kota',
//'filter'=>hlr_kota::model()->getOption(),
),
'hlr',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
'id'=>'hlr-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_hlr',
//'id_hlr_op',
//'id_hlr_kota',
array(
'header'=>'KOTA',
'name'=>'id_hlr_kota',
'value'=>'$data->hlr_kota->hlr_kota',
//'filter'=>hlr_kota::model()->getOption(),
),
'hlr',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Tidak ada komentar:
Posting Komentar