diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 4d3cd88660..c0324d5c1d 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -305,6 +305,8 @@ class BoundField(RenderableFieldMixin): if self.auto_id and not self.is_hidden: if self.help_text: aria_describedby.append(f"{self.auto_id}_helptext") + if self.errors: + aria_describedby.append(f"{self.auto_id}_error") return " ".join(aria_describedby) @property diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 494f3f244e..f068c31a93 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -986,14 +986,16 @@ the ``Form``, then the latter ``field_order`` will have precedence. You may rearrange the fields any time using ``order_fields()`` with a list of field names as in :attr:`~django.forms.Form.field_order`. +.. _form-error-display: + How errors are displayed ------------------------ If you render a bound ``Form`` object, the act of rendering will automatically run the form's validation if it hasn't already happened, and the HTML output -will include the validation errors as a ``
- +
- +
- +
""", ) self.assertHTMLEqual( @@ -239,15 +248,15 @@ This field is required. '