I created an Article and Comment Models and have CRUD on both. Its works perfectly. What I need now is to have the article.title field displayed in Comment Crud instead of the comment.articleid. How can I do that?
This is where I'm stuck. I don't know what to do next or if that's correct:
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(
'article'=>array(self::BELONGS_TO, 'Article', 'articleid')
);
}
EDIT:
Here's my code admin.php view file:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'comment-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'commentid',
'articleid',
'content',
'author',
'email',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Thanks.
it would be something like this for the columns array:
'columns'=>array(
'commentid',
array(
'name'=>'title',
'value'=>'$data->article->title',
'type'=>'text'
),
'content',
'author',
'email',
array(
'class'=>'CButtonColumn',
),
),