how to insert when multiple checkboxlist values are selected

hi all,

  I have a problem in inserting multiple selected values in a checkboxlist.

How to handle model in this case. can anyone help me.

I am able to display the column values as checkboxlist.

The code i am working with is





				$model=new Flatchargesmapping;

        $chargecode= array();

        $modelcharge = new Flatchargesmapping;

		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


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

		{

			$modelcharge->attributes=$_POST['Flatchargesmapping'];

			$chargecode = $modelcharge->Charge_code;

            $flag= "false";

        for ($i=0;$i<count($chargecode);$i++)

         {




         				$model=new Flatchargesmapping;


         		 $model->flat_number = $modelcharge->flat_number;

		          		 $model->Charge_code = $chargecode[$i];

		          		 if($model->save())

		          		 {

		          		    $flag="true";

                  		 }


				  if (!$model->save()) {


  								 	 echo "didn't work";

								     Yii::app()->end(); // don't use die();

				     	 	}

         }


				if($flag="true")

				$this->redirect(array('index','id'=>$model->id));

		}


		$this->render('create',array(

			'model'=>$model,

		));

Take a look at this:

http://www.yiiframework.com/doc/guide/1.1/en/form.table