Question

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)),
    )
);
Was it helpful?

Solution

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)),
    )
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top