Dear Friend
As I have similar problem in saving array from checkbox list in database.
Before saving it I converted it to string.
Before displaying it, I converted it again to array.
This way when validation fails or during update the checkbox list is nicely updated.
public function actionCreate()
{
$model=new Habit;
if(isset($_POST['Habit']))
{
$model->attributes=$_POST['Habit'];
if($model->habits!=='')
$model->habits=implode(',',$model->habits);//converting to string...
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$model->habits=explode(',',$model->habits);//converting to array...
$this->render('create',array(
'model'=>$model,
));
}
public function actionUpdate($id)
{
$model=$this->loadModel($id);
if(isset($_POST['Habit']))
{
$model->attributes=$_POST['Habit'];
if($model->habits!=='')
$model->habits=implode(',',$model->habits);
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$model->habits=explode(',',$model->habits);
$this->render('update',array(
'model'=>$model,
));
}
Regards.