Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Symfony2 Bootstrap checkbox inline style?

Tags:

twig

symfony

The Symfony2 Boostrap template has a conditional switch on 'checkbox-inline'. How is this triggered?

{% if 'checkbox-inline' in parent_label_class %}
    {{- form_label(form, null, { widget: parent() }) -}}
like image 873
Interlated Avatar asked Jul 02 '15 05:07

Interlated


1 Answers

Since the conditional check is looking in parent_label_class, you can simply add to your form builder an option called label_attr, and there you can append your class.

Example:

$builder->add('checkbox', 'checkbox',
    array(
       'label_attr' => array(
           'class' => 'checkbox-inline'
       )
    )
);

Which would give the following output:

<div class="checkbox">
    <label class="checkbox-inline required">
        <input type="checkbox" id="form_checkbox" name="form[checkbox]" required="required" value="1" />Checkbox
    </label>
</div>
like image 57
Artamiel Avatar answered Nov 15 '22 10:11

Artamiel