相关疑难解决方法(0)

在Yii框架中,如何组合列并在下拉列表中显示为显示字符串

我有一个dropDownList在我看来,它是由填充clients表,表中包含样柱first_name,last_name,id等等,现在我想展示first_namelast_name作为显示文本和id在下拉列表中的值,我有做id的价值和first_name作为显示文本,但在这里我想组合这些列(first_namelast_name)并用作显示文本.

在模型中

function getClients()
{
    $Clients = Client::model()->findAll();
    $list    = CHtml::listData($Clients , 'client_id', 'first_name');
    return $list;
}
Run Code Online (Sandbox Code Playgroud)

在视野中

echo $form->dropDownList($model,'client_id',$model->getClients());
Run Code Online (Sandbox Code Playgroud)

php yii virtual-attribute html.dropdownlistfor yii-cmodel

9
推荐指数
2
解决办法
1万
查看次数