Checkboxlist In Yii Framework Multiple Check Box List With Css


(Srikanth Maggidi14) #1

In View::


<?php $list=CHtml::listData(Stores::model()->findAll(), 'id','store_name'); //for check box list ?>

	

	<?php echo $form->checkBoxList($model, 'event_store',$list,array(

				'separator'=>'',

				'template'=>'<div>{input}&nbsp;{label}</div>',

				'value'=>1,'uncheckValue'=>0,'checked'=>($model->event_id=='' and $model->event_id!=0 )?true:$model->event_store)); ?>

In Controller ::


<?php	

$model=new Events; 	

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

				{

					$model->attributes=$_POST['Event'];

					if($_POST['Event']['event_store']==0)

					$model->event_store=$_POST['Event']['event_store'];

					

					if($_POST['Event']['event_store']!=NULL&&$_POST['Event']['event_store']!=0)

					$model->event_store=implode(",",$_POST['Events']['event_store']);

					

					if($model->save())

					{

						$this->redirect(array('action'));		//here redirect action			

								//or

						$this->render('view');					//here render to view

					}						

				}

				

//Note:: 				

				$model->event_store=explode(',',$model->event_store); //while update the check box before render to view, need to add this line.

				

?>

Thanks

Srikanth


(Srikanth Maggidi14) #2

Yii Multiple checkbox list with CSS enable feature

Check enable


(sandeepa) #3

This does not support yii2. how can this be modified to support?