How to specify Symfony2 Bootstrap checkbox inline style?

The Symfony2 Boostrap template has a checkbox-inline conditional switch. How does it work?

{% if 'checkbox-inline' in parent_label_class %} {{- form_label(form, null, { widget: parent() }) -}} 
+5
source share
1 answer

Since the conditional check looks in parent_label_class , you can simply add a parameter called label_attr to your form constructor, and there you can add your class.

Example:

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

Which will give the following result:

 <div class="checkbox"> <label class="checkbox-inline required"> <input type="checkbox" id="form_checkbox" name="form[checkbox]" required="required" value="1" />Checkbox </label> </div> 
+11
source

All Articles