Eselect2是正在使用的扩展,myADropDown()获取数据并显示,但是我需要在下拉列表中连接两个或多个列
model1视图
<?php $this->widget('ext.select2.ESelect2', array(
'name' => 'id',
'model' => $model,
'options' => array(
'placeholder' => $model->getAttributeLabel('id'),
),
'data' => $model->myADropDown(),
));?>
model1
public function getConcatened()
{
return $this->name.' '.$this->locate.' '.$this->rating;
}
public function myADropDown()
{
$vid=Yii::app()->SESSION['vid'];
$gid=Model2::model()->xyz($vid);
$list=CHtml::listData($gid,'id','concatened');
return $list;
}
// id是另一个tbl中的fk。
在下拉列表中,我需要的是名称、位置、每个人的评级,无法做到。
请告诉我如何做到这一点。
发布于 2014-01-15 06:15:00
若要连接列表数据中的表字段,请查看本Yii论坛答案:
链接
根据链接建议,您需要在模型中添加一个函数以获得连接字符串。
public function __get($key){
$action = 'get'.str_replace(' ','',ucwords(str_replace('_',' ',$key)));
if(method_exists($this, $action)) return $this->$action();
return parent::__get($key);
}
https://stackoverflow.com/questions/21130214
复制相似问题