Use Of Jmultiselect2Side Widget In Yii

Download yii jmultiselect2side widget [html]http://www.yiiframework.com/extension/jmultiselect2side/[/html]

Please follow the steps to create multiple selection of values and get selected values store into database.

at view::




<? $cities=array("Fremont"=>"Fremont","Heyward"=>"Heyward","Oalankd"=>"Oalankd","SanJose"=>"SanJose","SantaClara"=>"SantaClara","Sunny Vale"=>"Sunny Vale");?>

<?php  $this->widget('application.extensions.jmultiselect2side.Jmultiselect2side',array(

					'model'=>$citymodel,

					'attribute'=>'city_name', //selected items

					'labelsx'=>'Available',

					'labeldx'=>'Selected',

					'moveOptions'=>false,

					'autoSort'=>'true',

					'search' =>'Seach:',

					//'list'=>CHtml::listData($codes,'city_name','city_name'), // or use any model to get values from database eg: <?php $codes = City::model()->findAll();?>

					'list'=>$cities,

					));	?>

In Controller to get selected values and save into to database::




	public function actionCities($id)

	{

			$criteria = new CDbCriteria;

       		$criteria->condition = 't.region_id=:regionid';

       		$criteria->params = array(':regionid'=>$id);

        	$exists = RegionCities::model()->exists($criteria);

        	if (!$exists)

			{

			$citymodel=new RegionCities;

			$citymodel->region_id=$id;

			}

			else

			{

			$citymodel=RegionCities::model()->findByAttributes(array('region_id'=>$id));	

			$citymodel->region_id=$id;

			}

		

			if(isset($_POST['RegionCities'])&&!isset($_POST['cancel']))

			{

				$citymodel->attributes=$_POST['RegionCities'];

				$citymodel->region_id=$id;

				if(isset($_POST['RegionCities']['city_name']))

				{

				if($_POST['RegionCities']['city_name']!=NULL&&$_POST['RegionCities']['city_name']!=0)

					$citymodel->city_name=implode(";",$_POST['RegionCities']['city_name']);

				}	

				else	

				{

				$citymodel->city_name=NULL;

				}

				if($citymodel->save())

				{

				Yii::app()->user->setFlash('success', "Update successfully");

				$this->redirect(array('admin'));

				}

			}

			if (isset($_POST['cancel'])) 

			{

				$this->redirect(array('admin'));

			}

			if(isset($citymodel->city_name))

			$citymodel->city_name=explode(';',$citymodel->city_name);

			$this->render('cities',array('citymodel'=>$citymodel));

	}






Please post for any queries in jmultiselect2side widget.

Thanks,

Srikanth

how to create multiple into database? please.