summaryrefslogtreecommitdiff
path: root/docs/ref/forms/fields.txt
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2023-11-15 20:51:00 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-11-16 12:23:42 +0100
commit292f1ea90f90ff140617299a25884c8fda24aa64 (patch)
treebb67ccacb058a198be8a3beedca72fffce4e620f /docs/ref/forms/fields.txt
parent61c305f298da1b4079a80721c861d0663dc8717e (diff)
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>`.
Diffstat (limited to 'docs/ref/forms/fields.txt')
-rw-r--r--docs/ref/forms/fields.txt6
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index df9732f1af..9dff2d4007 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