How do you client validate what is generated using checkboxList() ?

Hi guys,

I have this:




<div class="col-right">

                            <?= $form->field($post, 'categories[]', [

                                'options' => [

                                    'class' => 'form-group'

                                ]

                            ])->checkboxList(ArrayHelper::map(Category::all(), 'id', 'name'), [

                                'unselect' => null,

                                'tag'      => 'ul',

                                'class'    => 'opts',

                                'item'     => function ($index, $label, $name, $checked, $value) {

                                    $item = Html::checkbox($name, $checked, [

                                        'id'           => 'category_id_' . $value,

                                        'uncheck'      => null,

                                        'label'        => null,

                                        'class'        => 'chk',

                                        'value'        => $value,

                                    ]);

                                    $item .= Html::label($label, 'category_id_' . $value, ['class' => 'chk full-width']);

                                    return $item;

                                }

                            ])->label(false);

                            ?>

                        </div>



Which generates a nice checkbox list, where selecting at least on option should be required. The required validator does not work on this (client side) so i had to write a new validator to validate this scenario.

Is this the right thing to do here, is the required validator unable to validate arrays?