@@ -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
@@ -104,17 +119,6 @@ Symfony Form ``RadioType`` and ``CheckboxType`` by adding some classes to the la
104119 {{ form_row(form.myCheckbox, {label_attr: {class: 'checkbox-custom'} }) }}
105120 {{ form_row(form.myCheckbox, {label_attr: {class: 'switch-custom'} }) }}
106121
107- Labels and Errors
108- -----------------
109-
110- When you use the Bootstrap form themes and render the fields manually, calling
111- ``form_label() `` for a checkbox/radio field doesn't render anything. Due to Bootstrap
112- internals, the label is already rendered by ``form_widget() ``.
113-
114- Form errors are rendered **inside ** the ``<label> `` element to make sure there
115- is a strong connection between the error and its ``<input> ``, as required by the
116- `WCAG 2.0 standard `_.
117-
118122 .. _`WCAG 2.0 standard` : https://www.w3.org/TR/WCAG20/
119123.. _`custom forms` : https://getbootstrap.com/docs/4.4/components/forms/#custom-forms
120124.. _`custom radio` : https://getbootstrap.com/docs/4.4/components/forms/#radios
0 commit comments