Retaining checked values of checkboxes populated from database

I have a model called


ComplainType

, so


$complain_type=ComplainType ::find ()->all()

will pass all values needed to populate the checkbox in view .

In the view file the following code will display the checkboxes


$model->complains = $complain_type;


$list = $complain_type;


$options = \yii\helpers\ArrayHelper::map($list, 'id', 'complains');




echo $form->field($model, 'complains')->checkboxList($options);

and the checked values need to be stored in another table called tbl_ticket_complain .

The problem I am facing is the retaining of the checked values while submiting. It is not getting retaining, in case of error. Can you help me in fixing this issue ?

Thanks