This can be done by passing this in your html options for the drop down list.
dropDownList($testcontroller, 'testid', CHtml::listData(Phases::model()->findAllByAttributes(array('pid'=>$pid)), 'id', 'phaseName'), array('options' => array('78'=>array('selected'=>true))));
and 78 will be selected.
for a hint, you can do something like this:
dropDownList($testcontroller,'testid', CHtml::listData(Phases::model()->findAll(), 'id', 'phasename'), array('empty'=>'Select an option'));
check this out for help . Thanks.
Coder anonymous
source share