Drop down menu yii->;下拉列表->;CHtml::listData->;设置选定值
如何在以下语句中设置所选值:Drop down menu yii->;下拉列表->;CHtml::listData->;设置选定值,drop-down-menu,yii,selected,yii-chtml,Drop Down Menu,Yii,Selected,Yii Chtml,如何在以下语句中设置所选值: echo $form->dropDownList( $model, 'land_id', CHtml::listData(ListeLand::model()->findAll(), 'iso', 'landname'), array('class'=>'span4 chosen','maxlength'=>20) ); 我想在列表中设置: iso = AT landname = Österreich 作为
echo $form->dropDownList(
$model,
'land_id',
CHtml::listData(ListeLand::model()->findAll(), 'iso', 'landname'),
array('class'=>'span4 chosen','maxlength'=>20)
);
我想在列表中设置:
iso = AT
landname = Österreich
作为选定值
已编辑->解决方案:
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)),
)
);
这很有效
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)),
)
);
找到解决方案:
'options'=>array('AT'=>array('selected'=>true)),
其他选项是设置$model->land_id='AT'
@E2B您应该输入您的解决方案作为答案,并将其标记为正确答案。好的,我已经完成了。但我明天才能接受。