Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create yii2 inline checkbox list

I have described my problem on yii2 forum, but no one helped me, most likely because no one knows the answer.

Here is the short description here.

I would like to make this:

<label class="checkbox-inline"><input type="checkbox" value="ASD">Option 1</label>
<label class="checkbox-inline"><input type="checkbox" value="DSA">Option 2</label>
<label class="checkbox-inline"><input type="checkbox" value="REW">Option 3</label>

but with yii2 checkboxList Html helper.

This is my simplified array of checkbox values

<?= $form->field($model, 'country')->checkboxList(['FR'=>'France', 'DE'=>'Germany']) ?>

I need to insert the class="checkbox-inline" into the label tags of each checkbox generated by this yii2 helper method but I can not figure out how to do it.

I was following these guides: checkboxList and checkbox one ( I can't post more than 2 links because I am new here ) but they are not helpful to me, I just do not understand what I have to do. Everything I tried just failed.

Can someone help me please, I am trying for 3 days now ?

like image 253
black-room-boy Avatar asked Dec 26 '14 12:12

black-room-boy


1 Answers

You should simply use :

<?= $form->field($model, 'country')->inline(true)->checkboxList(['FR'=>'France', 'DE'=>'Germany']) ?>

http://www.yiiframework.com/doc-2.0/yii-bootstrap-activefield.html#inline()-detail

like image 142
soju Avatar answered Nov 11 '22 12:11

soju