I want to apply css class to checkbox-list options.
I have this in my code:
<?= $form->field($searchModel, 'colour')
->checkboxList(ArrayHelper::map(app\modules\admin\models\ShoeColour::find()->all(), 'id', 'colour'),
([ 'itemOptions'=>['class'=>'my-own-custom-class']])) ?>
and the generated html is like this:
<div class="form-group field-productsearch-colour">
<label class="control-label">Colour</label>
<input type="hidden" name="ProductSearch[colour]" value=""><div id="productsearch-colour"><label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="1"> Red</label>
<label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="2"> Blue</label>
<label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="3"> Pink</label>
<label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="4"> Black</label>
<label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="5"> Brown</label>
<label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="6"> Grey</label>
<label><input type="checkbox" class="my-own-custom-class" name="ProductSearch[colour][]" value="7"> White</label></div>
<div class="help-block"></div>
</div>
I have in my table shoe_color - column as css_class for each color and I want to apply the css class for each, not able to make out how I can achieve that.
like instead of my-own-custom-class I want to have class-1,class-2 and so on.