我有2個模型:1個爲網站,1個爲產品;Yii網格列值
產品知道他屬於網站x;在表產品我已經website_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(
'relation_website' => array(self::BELONGS_TO,'Website','website_id'),
);
}
在產品模型的視圖管理,我有:
$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筆記本宏碁Aspire V3-571G-73614G50Maii立體處理器英特爾®酷睿TM i7-3610QM 2.30GHz,Ivy Bridge,4GB,500GB,nVidia GeForce GT 640M 2GB,Linpus,黑色3099.99 RON 1 < - 在這裏這個值
,而不是過去的1我想打印http://www.eshop.com/,存儲在網站上表中的值,屬於網站模型表
1筆記本宏碁Aspire V3-571G-73614G50Maii立方米。處理器英特爾酷睿™i7-3610QM 2.30GHz,Ivy Bridge的,4GB,500GB的NVIDIA GeForce GT 640M 2GB,百資,黑色3099.99 RON http://www.domain.com/
沒關係,我想通了:'價值'=>'$ data-> relation_website->網站', –