I have the following active drop down list
<?php
echo CHtml::activeDropDownList($project, 'city', CHtml::listData(City::model()->findAll(), 'id', 'name'), array('class'=>'st-form', 'onchange' => 'getLocationByCity(this)'));
?>
I want to add selected option to the 10th value in the drop down list when the list is being created, how do I do it.
Thanks.
The drop down list automatically selects the option corresponding to the value of the specified attribute of the specified model. In this case, the option with value equal to
$project->cityis preselected.So if you want to control which option that is, simply do
before calling
activeDropDownList.It doesn’t (and shouldn’t) matter if that option is 1st, 10th, or anything else.