Reputation: 1987
I have this call to output a set of checkboxes within my view:
<?=$this->Form->input('roles._ids', [
'options' => $roles,
'label' => false,
'multiple' => 'checkbox',
'templates' => [
'checkboxWrapper' => '<label class="mt-checkbox">{{label}}<span></span></label>',
'nestingLabel' => '{{input}}{{text}}',
'inputContainer' => '<div class="col-md-1" style="padding-top: 10px;"><div class="mt-checkbox-list" data-error-container="#form_2_services_error">{{content}}</div></div>'
]]);
?>
Does anyone know a solution - how to break the output into 2 divs? I wanted to have half the checkboxes in a single
<div class="col-md-1" style="padding-top: 10px;">
(see line "inputContainer") div container. Is that anyhow possible?
Upvotes: 1
Views: 94
Reputation: 2625
If you want to separate checkbox in two columns you can do like this
<?php
$this->Form->templates([
'checkboxWrapper' => '<div class="col-md-6">{{label}}</div>'
]);
?>
<?=$this->Form->input('roles._ids', [
'options' => ['asdasd','asdasd','asdasd'],
'label' => false,
'multiple' => 'checkbox',
]);
?>
OR you can just change the style of default template of cakehphp by adding this css
.checkbox {
width: 49%;
display: inline-block;
}
Hope this will help
Upvotes: 3