yii -> dropDownList -> CHtml::listData -> 设置选定值

2024-01-09

如何在以下语句中设置所选值:

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)),
    )
);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

yii -> dropDownList -> CHtml::listData -> 设置选定值 的相关文章