Answer the question
In order to leave comments, you need to log in
How to customize checkboxList in Yii2?
Good afternoon.
There is a code:
foreach($types as $ck => $cv){
$naa[$cv['id']] = $cv['name'];
}
echo $form->field($eventMain,'type',[
'template' => "<label for=''>Выберите тип</label>
$chechBoxexForTypeFilter
<div>{input}</div>",
'options' => ['class' => 'class-radioCheckBox']
])->checkboxList(
$naa,
[
// 1
'item' => function($index, $label, $name, $checked, $value) {
$return = '<label>';
$return .= '<input type="checkbox" name="' . $name . '"' . 'value="' . $value . '"' . ' >'."\n";
$return .= '<i class="fa fa-square-o fa-2x"></i>' ."\n" .
'<i class="fa fa-check-square-o fa-2x"></i>' ."\n";
$return .= '<span>' . ucwords($label) . '</span>' ."\n";
$return .= '</label>';
return $return;
},
'id' => 'simpleFilterModal_radioCheckBox'
]
);
Answer the question
In order to leave comments, you need to log in
function($index, $label, $name, $checked, $value)
checked isn't your responsibility for the parameter? check the default template.
In order for checked to be passed, $eventMain->type must have an array with checked values.
$eventMain->type = [1, 2, 5];
// а потом уже
...............
echo $form->field($eventMain,'type',[
'template' => "<label for=''>Выберите тип</label>
$chechBoxexForTypeFilter
<div>{input}</div>",
'options' => ['class' => 'class-radioCheckBox']
])
....................
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question