我有此调用以在我的视图中输出一组复选框:
<?=$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>'
]]);
?>
有谁知道解决方案-如何将输出分成2个div?我想在一个复选框中放一半复选框
<div class="col-md-1" style="padding-top: 10px;">
(请参见“ inputContainer”行)div容器。那有可能吗?
如果要将复选框分为两列,则可以这样操作
<?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',
]);
?>
或者您可以通过添加此CSS来更改cakehphp的默认模板的样式
.checkbox {
width: 49%;
display: inline-block;
}
希望这会有所帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句