5

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

1 Answer 1

11

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.