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