php - Ad Hoc Validation on checkboxlist yii2 -


i have activeform model

<?= $form->field($model, 'name')->textinput() ?> <?= $form->field($model, 'address')->textinput() ?> <?= $form->field($dynamicmodel, 'brands')->checkboxlist($brands); ?> ... 

i'm using ajax validation
want add validation checkboxlist

i found this: http://www.yiiframew...-hoc-validation
, this: http://www.yiiframew...hvalidator.html

but have no idea how use

and how assign values dynamic model?
it's junctiontable, know how them database, not how assign them

$dynamicmodel = \yii\base\dynamicmodel::validatedata(['brands'], [     [['brands'], 'required'],     ['brands', 'each', 'rule' => ['integer']], ]);  

i guess you:

// controller code:  $dynamicmodel = new dynamicmodel(); $dynamicmodel->defineattribute('brands', $value = null);  $dynamicmodel->addrule(['brands'], 'required']); $dynamicmodel->addrule(['brands', 'each', ['rule' => ['integer']]]);  // load submitted post data $dynamicmodel->load(yii::$app->request->post());  // validation $dynamicmodel->validate();   // view code <?= $form->field($dynamicmodel, 'brands')->checkboxlist(['1'=>'brand 1', '2'=>'brand 2']) ?> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -