Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying yii2 checkboxlist vertically

I have an active form which currently displays checkboxlists horizontally but I would like it to display them vertically. I have set the form layout to vertical but it still displays them horizontally:

This is what I have tried:

//generates an array of permissions 
$options = Permission::value_list(
   Permission::findWhere()->select('name')->andWhere(['not', ['name' => $name]])->all(),
        ['name']
    );

This is the form

   <?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") ?>

What do I need to add: currently they are displayed in this way.

enter image description here

I would like the displayed vertically.

like image 797
Geoff Avatar asked Nov 25 '25 09:11

Geoff


1 Answers

You could use the separator option mentioned here: http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#activeCheckboxList()-detail

Your call would then look like this for example:

<?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") ?>

Or whatever you want to use as the separator in your specific case.

Hope that helps...

like image 125
BlueZed Avatar answered Nov 28 '25 02:11

BlueZed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!