How to select the checkbox as ckecked in active form


I have the checkbox list in my form and I have a problem with update form…


$colors= ArrayHelper::map(Colors::find()->all(),'id','color');

<?= $form->field($model, 'colors[]')->checkboxList($colors); ?>

controller, function Create:

$model->colors = empty($model->colors) ? '' : implode(',', $model->colors);

It works fine, but how to select the checkboxes in Update Form as checked ?


Just the values in an array:

 $model->colors[] = /*Your ids here*/