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() }) -}}
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With