Hello everybody,
I’m new in Yii. It is really a great framework, indeed. Actually, I would like to ask about the relations to same table. For example I have a table below
TABLE SPESIALIS
id_spesialis
nama_spesialis
parent_id_spesialis [i](reference to id_spesialis itself)[/i]
My challenge is I want to display parent name in CGridView. I tried with this one below but it didn’t work
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'spesialis-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_spesialis',
'nama_spesialis',
'parent_id_spesialis',
array(
'name'=>'parent_id_spesialis',
'filter'=>CHtml::listData(Spesialis::model()->findAll(), 'id_spesialis', 'nama_spesialis'),
'value'=>Spesialis::model()->findByPk($model->parent_id_spesialis)->nama_spesialis,
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Should I define relations to solve this problem? But I think it will cost extra join.
Looking forward to your help.
Thanks in advance