Hi all
I have a problem with my checkBoxList: after my form has been sent (and the attributes saved), the selection of the checkboxes is gone.
But when I then access the page again without sending the form first, the correct checkboxes are selected again.
I save the value of the checkboxes as a serialized array to the database and unserialize in my model afterFind().
View:
<?php echo $form->checkBoxList($memberModel, 'qualification', array(
'qalification1',
'qalification2',
'qalification3'
)); ?>
Model:
protected function afterFind()
{
$this->qualification = unserialize($this->qualification);
}
Controller:
public function actionEdit()
{
$memberModel = Member::model()->findByPk(Yii::app()->user->info->id);
if (isset($_POST['Member'])) {
$memberModel->attributes = $_POST['Member'];
$memberModel->save();
}
// Render [...]
}
Why are my checkboxes not selected after my form has been sent, but when I reload the page without sending the form, they show?
Best regards
ycast