As per question’s title, I am strugling to pass a custom css class on each generated checkbox list using Yii2 form field.
Here is my function:
public function getItems()
{
$items = [];
foreach (explode("n", $this->options) as $option) {
if (strpos($option, '=>') !== false) {
list($key, $value) = explode('=>', $option);
$items[trim($key)] = Yii::t($this->propertyField->language_category, trim($value));
} else {
$items[] = Yii::t($this->propertyField->language_category, trim($option));
}
}
return $items;
}
As it is now i get this list:
<div class="form-group field-propertyfields">
<label class="form-label">Property Amenities</label>
<div id="propertyfields-7" class="multiselect-checkboxes">
<label><input type="checkbox" name="propertyFields[7][]" value="1">Elevator</label>
<label><input type="checkbox" name="propertyFields[7][]" value="2">Parking</label>
<label><input type="checkbox" name="propertyFields[7][]" value="3">Fireplace</label>
</div>
</div>
What i want is to add a custom class on each label of input so it look like this:
<label class="my-custom-class"><input type="checkbox" name="propertyFields[7][]"value="2">Parking</label>