Dropdownlist order???

I’m trying to order the elements of a dropdown list created like this:

$options = array(

            'selectedList' => 5,


            'minWidth' => 400,


            'header' => false,


        );

$this->widget(‘UJuiMultiselect’, array(‘id’=>‘tags’, ‘options’=>$options));

echo $form->dropDownList($model,‘tags’, CHtml::listData($tags,‘id’,‘name’), array(‘id’=>‘tags’,‘multiple’ => ‘multiple’));

but no luck, any help woul be greatly appreciated. Thank you.

The best way is probably to sort the data in the criteria of the query that $tags is coming from.

Alternately you could use asort(), however since it modifies an existing array rather than returning one it would require some slightly longer code




$listData = CHtml::listData($tags,'id','name');

asort($listData);


echo $form->dropDownList($model,'tags', $listData, array('id'=>'tags','multiple' => 'multiple'));