Content management system 网格列值
我有两个模型:一个用于网站,一个用于产品 产品知道他属于x网站;在表产品中,我有网站id 在产品中,我有以下关系:Content management system 网格列值,content-management-system,yii,Content Management System,Yii,我有两个模型:一个用于网站,一个用于产品 产品知道他属于x网站;在表产品中,我有网站id 在产品中,我有以下关系: 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(
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(
'relation_website' => array(self::BELONGS_TO,'Website','website_id'),
);
}
在产品模型的视图admin中,我有:
$dataProvider = $model->search();
$dataProvider->pagination->pageSize = 100;
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'product-grid',
'dataProvider' => $dataProvider,
'filter' => $model,
'columns' => array(
'id',
'product',
'price',
'currency',
array(
'name' => 'website_id',
'value' => $model->relation_website->website_id,
),
/*
'website_id',
'url_id',
*/
array(
'class' => 'CButtonColumn',
'template' => '{update}{delete}',
),
),
));
我现在有一个结果:
1台笔记本电脑Acer Aspire V3-571G-73614G50Maii cu procesor Intel'CoreTM i7-3610QM 2.30GHz常春藤桥4GB 500GB英伟达GeForce GT 640M 2GB Linpus黑色3099.99 RON 1看起来您需要的是:
...
'value' => '$data->relation_website->name'
...
在中有一个类似的例子,它是每个Yii开发人员的必读读物没关系,我算出了:'value'=>'$data->relationship\u website->website',我正在寻找chtml:))10x