Update release notes and customize aria-describedby

This commit is contained in:
Nimra Aftab 2022-10-16 11:39:25 -04:00
parent f76e008a99
commit 5a74c49eef
3 changed files with 11 additions and 7 deletions

View File

@ -279,12 +279,12 @@ class BoundField:
if self.field.disabled:
attrs["disabled"] = True
id_for_label = self.id_for_label
if (
self.field.help_text
and id_for_label
and "aria-describedby" not in widget.attrs
):
attrs["aria-describedby"] = "%s_helptext" % id_for_label
if self.field.help_text and id_for_label:
helptext_id = '%s_helptext' % id_for_label
if 'aria-describedby' in widget.attrs:
attrs['aria-describedby'] = f"{helptext_id} {attrs['aria-describedby']}"
else:
attrs['aria-describedby'] = helptext_id
return attrs
@property

View File

@ -284,7 +284,7 @@ template to make the same customization to the ``id`` of the help text.
>>> print(f['username'])
<input type="text" name="username" aria-describedby="custom-description" maxlength="10" id="id_username" required>
.. versionchanged:: 4.1
.. versionchanged:: 4.2
``aria-describedby`` was added to associate ``help_text`` with its input.

View File

@ -173,6 +173,10 @@ Forms
* :func:`~django.forms.models.modelform_factory` now respects the
``formfield_callback`` attribute of the ``form``s ``Meta``.
* Currently, help text is not programmatically identifiable. To improve accessibility
:attr:`~django.forms.Field.help_text` is now
associated to its input using ``aria-describedby``.
Generic Views
~~~~~~~~~~~~~