문제

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)),
    )
);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top