Answer the question
In order to leave comments, you need to log in
Customizing checkboxList()?
Good day. There is such a problem.
There is a code
<?=$form->field($model, 'created_at')->checkboxList(['Checkbox 1','Checkbox 2','Checkbox 3'],['class'=>'mt-checkbox-list', 'itemOptions' => ['labelOptions'=>['class'=>'mt-checkbox mt-checkbox-outline']]]); ?>
<div class="form-group field-users-created_at required">
<label class="control-label" for="users-created_at">Дата создания</label>
<input type="hidden" name="Users[created_at]" value=""><div id="users-created_at" class="mt-checkbox-list"><label class="mt-checkbox"><input type="checkbox" name="Users[created_at][]" value="0"> Checkbox 1</label>
<label class="mt-checkbox"><input type="checkbox" name="Users[created_at][]" value="1"> Checkbox 2</label>
<label class="mt-checkbox"><input type="checkbox" name="Users[created_at][]" value="2"> Checkbox 3</label></div>
<span class="help-block"></span>
</div>
<div class="form-group field-users-created_at required">
<label class="control-label" for="users-created_at">Дата создания</label>
<input type="hidden" name="Users[created_at]" value=""><div id="users-created_at" class="mt-checkbox-list"><label class="mt-checkbox"><input type="checkbox" name="Users[created_at][]" value="0"> Checkbox 1<span></span></label>
<label class="mt-checkbox"><input type="checkbox" name="Users[created_at][]" value="1"> Checkbox 2<span></span></label>
<label class="mt-checkbox"><input type="checkbox" name="Users[created_at][]" value="2"> Checkbox 3<span></span></label></div>
<span class="help-block"></span>
</div>
$this->template = "<div class='mt-checkbox-list'>{input}<span></span></div>";
Answer the question
In order to leave comments, you need to log in
$form->field($model, 'created_at')->checkboxList([
'Checkbox 1',
'Checkbox 2',
'Checkbox 3'
],[
'item' => function ($index, $label, $name, $checked, $value) {
return // генерируем чекбокс какой угодно структуры
}
])
Another question, I asked what I need to return
how do I pass parameters, that is, label itself add a class and input add an attribute.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question