0

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

rch
  • 345
  • 1
  • 6
  • 20

1 Answers1

1

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',
  ),
));
Asfandyar Khan
  • 1,677
  • 15
  • 34
  • cant we do anything without any extension..? – rch Feb 27 '17 at 09:50
  • Not really, thats why they have made extension, Its the easiest way to do.. Maybe there are some other extension too. but Select2 is best one, I have used it. – Asfandyar Khan Feb 27 '17 at 12:34
  • thq , above extension works fine but i want to have checkboxes to select in dropdownlist rather than selecting horizontal – rch Feb 27 '17 at 15:45
  • I think there is another one for checkboxes, i have not used it but you can try looking for Bootstrap MultiSelect with jquery. https://davidstutz.github.io/bootstrap-multiselect/ – Asfandyar Khan Feb 28 '17 at 05:59