Emultiselect In Cform

I try to share my code in

http://www.yiiframework.com/forum/index.php/topic/19399-extension-emultiselect

But it does not allow me to add my screen shots. So open a new topic.

Emultiselect is very nice extension. I used this in my wizard form. Although it took me a few hours to insert it into CForm.

4657

emultiselect.png

Share what I did, in case some people want to do same thing.

After you installed emultiselect into your /protected/widget/, you can not use this widget in the CForm as one element directly, But after you look into the EMultiSelect.php, you will find this widget is added jquery code to handle dropdown list. then what you need to do is added the code after $form in the view.




echo CHtml::tag('div',array('class'=>'form'),$form);

$this->widget(

		'application.widget.emultiselect.EMultiSelect',

		array(

			'sortable'=>true, 

			'searchable'=>true,

			'dividerLocation'=>0.5, //this is divide the column half-half. You need add this into EMultiSelect.php so it can handle that.

		)

);



Then in your wizard step model add drop down list into getForm() function.




$return=new CForm(array(

	'showErrorSummary'=>true,

	'elements'=>array(

		'<p>Search tools from available tool list, then click "+" to add into selected list.

		</p>',

		'tool_list'=>array(

			'type'=>'dropdownlist',

			'items'=>$avaliableToolList,//CHtml::listData(Costcenter::model()->findAll(), 'costcenter_id', 'costcenterFullName'),

			'label'=>'Available transfer tool list' ,

			'attributes'=>array(							

				'multiple'=>'multiple',

				'key'=>'trainings',

				'class'=>'multiselect',

			),

		),				

...