記事とコメントモデルを作成し、両方でCRUDを作成しました。その作品は完璧です。私が今必要とするのはcomment.articleidではなくComment Crudにarticle.titleフィールドを表示することです。どうやってやるの?コメントの記事タイトルを取得する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')
);
}
EDIT:
<?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',
),
),
)); ?>
ありがとう:
はここに私のコードadmin.phpのビューファイルです。
あなたの関係の機能上:モデルでありますこのコードは? –