How can I set the selected value in the following statement:
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 selected value.
EDITED -> The 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)),
)
);
this works..
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)),
)
);
来源:https://stackoverflow.com/questions/19938782/yii-dropdownlist-chtmllistdata-set-selected-value