Need listbox with multiple selection - in yii

bala picture bala · May 24, 2012 · Viewed 13.5k times · Source

I need listbox of multiple selection in yii, i have code of form area but its saving to database as a word "Array" in field, How to handle this problem?

how to get back while view and update and grid view also

<?php echo $form->dropDownList($model,'clients', 
  CHtml::listData(client::model()->findAll(array('order'=>'id')), 'id', 'name'),
     array('empty'=>'','multiple'=>'multiple','style'=>'width:400px;','size'=>'10'));
?>

Thank you.

Answer

CagunA picture CagunA · Jan 18, 2013

For me works this:

'multiple'=>true

Your code must be something like that:

<?php echo $form->dropDownList($model,'clients', 
  CHtml::listData(client::model()->findAll(array('order'=>'id')), 'id', 'name'),
     array('empty'=>'','multiple'=>true ,'style'=>'width:400px;','size'=>'10'));
?>