Interlated
Interlated

Reputation: 5926

How to specify Symfony2 Bootstrap checkbox inline style?

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() }) -}}

Upvotes: 5

Views: 8031

Answers (1)

Artamiel
Artamiel

Reputation: 3762

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>

Upvotes: 11

Related Questions