我创建了文章和评论模型,并在两者上都有CRUD。它的作品完美。我现在需要的是将article.title字段显示在Comment Crud中而不是comment.articleid中。我怎样才能做到这一点?获取文章标题的评论Crud
这是我卡住的地方。我不知道下一步该怎么做,或者如果这是正确的:
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')
);
}
编辑:
这里是我的代码admin.php的视图文件:
<?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',
),
),
)); ?>
感谢。
:哪种模式这段代码来自? –