phpdrop-down-menuyii

Selecting Multiple values in CHtml::dropdownlist yii


I have dropdownlist as

echo CHtml::dropDownList('personids', '',$list, array('id'=>'sea'.$dd,'class'=>'vulntr-textfld1','prompt'=>'Select',));

and the list data is

$criteria=new CDbCriteria();
$criteria->addCondition('PersonTypeCode=:PersonTypeCode AND FamilyId=:FamilyId ');
$criteria->params=array(':PersonTypeCode'=>$category,':FamilyId'=>$Familyid);
$lookupval = Person::model()->findAll($criteria);
$list = CHtml::listData($lookupval, 'PersonID', 'FirstName');

it is working well..but my question is how to select multiple values in this dropdownlist , please any suggestions would be appreciated


Solution

  • You will have to use a Yii Extension for selecting multiple dropdown values.. The name of extension is "Select2"

    Extension Details Here

    Download link for Select2

    Extract the downloaded file to your application extensions directory

    For selecting multiple values.. You should add htmlOptions to select multiple values.

    $list will be an array that you have send to this code.

    $this->widget('ext.select2.ESelect2',array(
      'name'=>'anything',
      'data'=>$list,
      'htmlOptions'=>array(
        'multiple'=>'multiple',
      ),
    ));