垂直显示 yii2 复选框列表
Displaying yii2 checkboxlist vertically
我有一个当前水平显示复选框列表的活动表单,但我希望它能垂直显示它们。我已经将表单布局设置为垂直,但它仍然水平显示:
这是我试过的:
//generates an array of permissions
$options = Permission::value_list(
Permission::findWhere()->select('name')->andWhere(['not', ['name' => $name]])->all(),
['name']
);
这是表格
<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?>
<?= $form->field($model, 'item_children')
->checkboxList($options)->label(sprintf("Available %s", $assigning))
->hint("Which type of authorization item are you creating") ?>
需要补充的是:目前是这样显示的
我想要垂直显示。
The label to use Note that this will NOT be encoded.
<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?>
<?= $form->field($model, 'country')
->inline(true)
->checkboxList($options)->label(sprintf("Available %s", $assigning))
->hint("Which type of authorization item are you creating") ?>
您可以使用此处提到的 separator
选项:http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#activeCheckboxList()-detail
您的电话将如下所示:
<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?>
<?= $form->field($model, 'item_children')
->checkboxList($options, ['separator'=>'<br/>'])
->label(sprintf("Available %s", $assigning))
->hint("Which type of authorization item are you creating") ?>
或者在您的特定情况下您想用作分隔符的任何内容。
希望对您有所帮助...
我有一个当前水平显示复选框列表的活动表单,但我希望它能垂直显示它们。我已经将表单布局设置为垂直,但它仍然水平显示:
这是我试过的:
//generates an array of permissions
$options = Permission::value_list(
Permission::findWhere()->select('name')->andWhere(['not', ['name' => $name]])->all(),
['name']
);
这是表格
<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?>
<?= $form->field($model, 'item_children')
->checkboxList($options)->label(sprintf("Available %s", $assigning))
->hint("Which type of authorization item are you creating") ?>
需要补充的是:目前是这样显示的
我想要垂直显示。
The label to use Note that this will NOT be encoded.
<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?>
<?= $form->field($model, 'country')
->inline(true)
->checkboxList($options)->label(sprintf("Available %s", $assigning))
->hint("Which type of authorization item are you creating") ?>
您可以使用此处提到的 separator
选项:http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#activeCheckboxList()-detail
您的电话将如下所示:
<?php $form = ActiveForm::begin(['layout' => 'vertical']); ?>
<?= $form->field($model, 'item_children')
->checkboxList($options, ['separator'=>'<br/>'])
->label(sprintf("Available %s", $assigning))
->hint("Which type of authorization item are you creating") ?>
或者在您的特定情况下您想用作分隔符的任何内容。
希望对您有所帮助...