I have 3 dependent dropdowns on my page for creation of entity.
echo CHtml::dropDownList('OpenLessons[Building]', '', $buildingList,array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('ajax/floorList'), //url to call.
'update'=>'#OpenLessons_Floor', //selector to update
)));
echo CHtml::dropDownList('OpenLessons[Floor]','', array(),array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('ajax/roomList'),
'update'=>'#OpenLessons_Class_ID',
)));
echo CHtml::dropDownList('OpenLessons[Class_ID]',$model->Class_ID, array());
Now I want to give them selected options while edit: I found how to give selected options. I found here how to do it. First select has this code:
<select name="OpenLessons[Building]" id="OpenLessons_Building">
<option value="19">primary school</option>
<option value="6">high school</option>
</select>
So, I want to set it's value to high school for example.
echo CHtml::dropDownList('OpenLessons[Building]', '', $buildingList,array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('ajax/floorList'),
'update'=>'#OpenLessons_Floor',
'options' => array('High school'=>array('selected'=>true)),
//Also tried this 'options' => array('6'=>array('selected'=>true)),
)));
And chosen value while editing entity is always - primary school. What's wrong? UPDATE @Tristup helped me to set value of first dropdown, but there are two more dependent dropdowns and I have problems with it. Here is my next question