我有一个填充了数据库的下拉列表。它适用于 1 个键和 1 个值。但是我如何让它与 1 个键和 2 个值一起工作。这两个值是名字和姓氏。
<?php
$id = Yii::app()->user->id;
$clients = Clients::model()->findAll(array("condition"=>"cId = $id"));
$list = CHtml::listData($clients, 'id', 'fname');
?>
<?php echo $form->labelEx($model,'clientId'); ?>
<?php echo CHtml::dropDownList('clientId', $model, $list, array(
'empty' => 'Select a client',
'class' => 'form-control'
)); ?>
<?php echo $form->error($model,'clientId'); ?>
//needs something like this
$list = CHtml::listData($clients, 'id', 'fname lname');