記事とコメントのモデルを作成し、両方に CRUD を設定しました。その作品は完全に。ここで必要なのは、comment.articleid の代わりに article.title フィールドを Comment 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',
),
),
)); ?>
ありがとう。