diff options
| author | David Smith <smithdc@gmail.com> | 2023-11-15 20:51:00 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-16 13:27:18 +0100 |
| commit | 7f0275d8cb6a590fa5e157cadeba776e9a790121 (patch) | |
| tree | 35826ad1d766f635ed85c87d630ed4fedf9f03c1 /docs | |
| parent | 8c88ae8251da7f4fa01c1422f76fbb73aa41fffa (diff) | |
[5.0.x] Refs #32819 -- Used auto_id instead of id_for_label as unique identifier 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>`.
Backport of 292f1ea90f90ff140617299a25884c8fda24aa64 from main
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/fields.txt | 6 | ||||
| -rw-r--r-- | docs/releases/5.0.txt | 6 | ||||
| -rw-r--r-- | docs/topics/forms/index.txt | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 8371a32dfd..91047ea758 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -283,9 +283,9 @@ fields. We've specified ``auto_id=False`` to simplify the output: <div>Sender:<div class="helptext">A valid email address, please.</div><input type="email" name="sender" required></div> <div>Cc myself:<input type="checkbox" name="cc_myself"></div> -When a field has help text and :attr:`~django.forms.BoundField.id_for_label` -returns a value, we associate ``help_text`` with the input using the -``aria-describedby`` HTML attribute: +When a field has help text and the widget is not rendered in a ``<fieldset>``, +``aria-describedby`` is added to the ``<input>`` to associate it to the +help text: .. code-block:: pycon diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index db75a6b0a3..269e3b382e 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -61,7 +61,7 @@ For example, the template below: <div> {{ form.name.label_tag }} {% if form.name.help_text %} - <div class="helptext" id="{{ form.name.id_for_label }}_helptext"> + <div class="helptext" id="{{ form.name.auto_id }}_helptext"> {{ form.name.help_text|safe }} </div> {% endif %} @@ -71,7 +71,7 @@ For example, the template below: <div class="col"> {{ form.email.label_tag }} {% if form.email.help_text %} - <div class="helptext" id="{{ form.email.id_for_label }}_helptext"> + <div class="helptext" id="{{ form.email.auto_id }}_helptext"> {{ form.email.help_text|safe }} </div> {% endif %} @@ -81,7 +81,7 @@ For example, the template below: <div class="col"> {{ form.password.label_tag }} {% if form.password.help_text %} - <div class="helptext" id="{{ form.password.id_for_label }}_helptext"> + <div class="helptext" id="{{ form.password.auto_id }}_helptext"> {{ form.password.help_text|safe }} </div> {% endif %} diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 7b27e98996..55d032c9bb 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -723,7 +723,7 @@ loop: {{ field.errors }} {{ field.label_tag }} {{ field }} {% if field.help_text %} - <p class="help" id="{{ field.id_for_label }}_helptext"> + <p class="help" id="{{ field.auto_id }}_helptext"> {{ field.help_text|safe }} </p> {% endif %} |
