如何在CDetailView Yii中列名不同的情况下显示来自外键的数据
表格1
x1 x2
1 sample text 1
2 sample text 2
3 sample text 3
表2
y1 y2 y3 (foreign key x1)
1 text 1 1
2 text 2 1
3 text 3 2
我想显示以下结果
y1 y2 y3
1 text 1 sample text 1
2 text 2 sample text 1
3 text 3 sample text 2
这是模型类中的关系代码
public function relations(){
return array(
'Table2' => array(self::BELONGS_TO, 'Table1', array('x1'=>'y3'))
);
}
这是我的 CDetailView 代码
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
array(
'name'=>'Table2.y3',
'value'=>$model->Table2->x2,
),
'y1',
'y2'
),
)); ?>
我收到以下错误
Property "Table2.x1" is not defined.