-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refs #32819 -- Used auto_id instead of id_for_label as unique identifier for the field. #17480
Conversation
docs/ref/forms/fields.txt
Outdated
@@ -395,7 +395,7 @@ be ignored in favor of the value from the form's initial data. | |||
.. versionadded:: 5.0 | |||
|
|||
The ``template_name`` argument allows a custom template to be used when the | |||
field is rendered with :meth:`~django.forms.BoundField.as_field_group`. By | |||
field is rendered with :meth:`~django.forms.BoundField.as_field_group`. By |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to commit a change to this file without adding this whitespace change.
): | ||
attrs["aria-describedby"] = f"{self.id_for_label}_helptext" | ||
attrs["aria-describedby"] = f"{self.auto_id}_helptext" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added in 966ecdd (Django 5.0). I'd recommend backporting this change to the Django 5.0 to avoid changes in Django 5.1 in recently added functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable.
I was wondering if you may have triaged the other pr as a release blocker. I think it's not as we we've only recently agreed on a way forward for fields with related <inputs>
.
4da6fc1
to
00b8ba3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smithdc1 Thanks 👍 I pushed small docs changes, assuming this change would be backported.
…ier for the field. `id_for_label` is blank for widgets with multiple inputs such as radios and multiple checkboxes. Therefore , `help_text` for fields using these widgets cannot currently be associated using `aria-describedby`. `id_for_label` is being used as a guard to avoid incorrectly adding `aria-describedby` to those widgets. This change uses `auto_id` as the unique identified for the fields `help_text`. A guard is added to avoid incorrectly adding `aria-describedby` to inputs by checking the widget's `use_fieldset` attribute. Fields rendered in a `<fieldset>` should have `aria-describedby` added to the `<fieldset>` and not every `<input>`.
00b8ba3
to
292f1ea
Compare
id_for_label
is blank for widgets with multiple inputs such as radios and multiple checkboxes. Therefore ,help_text
for fields using these widgets can not currently be associated usingaria-describedby
.id_for_label
is being used as a guard to avoid incorrectly addingaria-describedby
to those widgets.This change uses
auto_id
as the unique identified for the fieldshelp_text
. A guard is added to avoid incorrectly addingaria-describedby
to inputs by checking the widget'suse_fieldset
attribute. Fields rendered in a<fieldset>
should havearia-describedby
added to the<fieldset>
and not every<input>
.