summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2023-11-12 17:24:16 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-11-17 08:12:36 +0100
commiteec7e9ba894a7815d289ba7446eeead488fe0e33 (patch)
tree8eed8c3d9182470731667c40758aced7f719a119 /django/forms
parent557fa51837a57534f8ca486133a412547a98a37e (diff)
Refs #32819 -- Established relationship between form fieldsets and their help text.
This adds aria-describedby for widgets rendered in a fieldset such as radios. aria-describedby for these widgets is added to the <fieldset> element rather than each <input>.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/jinja2/django/forms/field.html2
-rw-r--r--django/forms/templates/django/forms/field.html5
2 files changed, 3 insertions, 4 deletions
diff --git a/django/forms/jinja2/django/forms/field.html b/django/forms/jinja2/django/forms/field.html
index 21035b72e4..642d45ddc7 100644
--- a/django/forms/jinja2/django/forms/field.html
+++ b/django/forms/jinja2/django/forms/field.html
@@ -1,5 +1,5 @@
{% if field.use_fieldset %}
- <fieldset>
+ <fieldset{% if field.help_text and field.auto_id and "aria-describedby" not in field.field.widget.attrs %} aria-describedby="{{ field.auto_id }}_helptext"{% endif %}>
{% if field.label %}{{ field.legend_tag() }}{% endif %}
{% else %}
{% if field.label %}{{ field.label_tag() }}{% endif %}
diff --git a/django/forms/templates/django/forms/field.html b/django/forms/templates/django/forms/field.html
index f8b0cdedd5..a4548fe54f 100644
--- a/django/forms/templates/django/forms/field.html
+++ b/django/forms/templates/django/forms/field.html
@@ -1,10 +1,9 @@
{% if field.use_fieldset %}
- <fieldset>
+ <fieldset{% if field.help_text and field.auto_id and "aria-describedby" not in field.field.widget.attrs %} aria-describedby="{{ field.auto_id }}_helptext"{% endif %}>
{% if field.label %}{{ field.legend_tag }}{% endif %}
{% else %}
{% if field.label %}{{ field.label_tag }}{% endif %}
{% endif %}
{% if field.help_text %}<div class="helptext"{% if field.auto_id %} id="{{ field.auto_id }}_helptext"{% endif %}>{{ field.help_text|safe }}</div>{% endif %}
{{ field.errors }}
-{{ field }}
-{% if field.use_fieldset %}</fieldset>{% endif %}
+{{ field }}{% if field.use_fieldset %}</fieldset>{% endif %}