Yii & # 8594; dropDownList & # 8594; CHtml :: listData & # 8594; set selected value
How to set the selected value in the following expression:
echo $form->dropDownList(
$model,
'land_id',
CHtml::listData(ListeLand::model()->findAll(), 'iso', 'landname'),
array('class'=>'span4 chosen','maxlength'=>20)
);
I want to set in the list:
iso = AT
landname = Γsterreich
as the selected value.
EDITED -> Solution:
echo $form->dropDownList(
$model,
'land_id',
CHtml::listData(ListeLand::model()->findAll(), 'iso', 'landname'),
array(
'class'=>'span4 chosen',
'maxlength'=>20,
'options' => array('AT'=>array('selected'=>true)),
)
);
+1
user2227400
source
to share