I have an activeForm with model
<?= $form->field($model, ‘name’)->textInput() ?>
<?= $form->field($model, ‘address’)->textInput() ?>
<?= $form->field($dynamicModel, ‘brands’)->checkboxList($brands); ?>
…
I’m also using ajax validation
Now I want to add validation to the checkboxlist
I found this: http://www.yiiframework.com/doc-2.0/guide-input-validation.html#ad-hoc-validation
and this: http://www.yiiframework.com/doc-2.0/yii-validators-eachvalidator.html
But I have no idea how to use it
And how to I assign the values to the dynamic model?
It’s from a junctiontable, I know how to get them from the database, but not how to assign them
$dynamicModel = \yii\base\DynamicModel::validateData([‘brands’], [
[['brands'], 'required'],
['brands', 'each', 'rule' => ['integer']],
]);