@@ -77,6 +77,21 @@ If you prefer to apply the Bootstrap styles on a form to form basis, include the
7777 {{ form(form) }}
7878 {% endblock %}
7979
80+ Error Messages
81+ --------------
82+
83+ Form errors are rendered **inside ** the ``<label> `` element to make sure there
84+ is a strong connection between the error and its ``<input> ``, as required by the
85+ `WCAG 2.0 standard `_. To achieve this, ``form_errors() `` is called by
86+ ``form_label() `` internally. If you call to ``form_errors() `` in your template,
87+ you'll get the error messages displayed *twice *.
88+
89+ Checkboxes and Radios
90+ ---------------------
91+
92+ For a checkbox/radio field, calling ``form_label() `` doesn't render anything.
93+ Due to Bootstrap internals, the label is already rendered by ``form_widget() ``.
94+
8095Accessibility
8196-------------
8297
@@ -108,17 +123,6 @@ Symfony Form ``RadioType`` and ``CheckboxType`` by adding some classes to the la
108123 {{ form_row(form.myCheckbox, {label_attr: {class: 'checkbox-custom'} }) }}
109124 {{ form_row(form.myCheckbox, {label_attr: {class: 'switch-custom'} }) }}
110125
111- Labels and Errors
112- -----------------
113-
114- When you use the Bootstrap form themes and render the fields manually, calling
115- ``form_label() `` for a checkbox/radio field doesn't render anything. Due to Bootstrap
116- internals, the label is already rendered by ``form_widget() ``.
117-
118- Form errors are rendered **inside ** the ``<label> `` element to make sure there
119- is a strong connection between the error and its ``<input> ``, as required by the
120- `WCAG 2.0 standard `_.
121-
122126 .. _`WCAG 2.0 standard` : https://www.w3.org/TR/WCAG20/
123127.. _`custom forms` : https://getbootstrap.com/docs/4.4/components/forms/#custom-forms
124128.. _`custom radio` : https://getbootstrap.com/docs/4.4/components/forms/#radios
0 commit comments