#36724: BoundField adds invalid "for" attribute on <legend> tags
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Varun
| Kasyap Pentamaraju
Type: Bug | Status: assigned
Component: Forms | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):
* component: contrib.admin => Forms
* needs_better_patch: 0 => 1
* needs_tests: 1 => 0
* summary: FilteredSelectMultiple widget has broken "for" attribute on
<legend> => BoundField adds invalid "for" attribute on <legend> tags
Comment:
Reframing the issue to fix the 4.1 feature that added `<legend>` usage in
`BoundField` (eba9a9b7f72995206af867600d6685b5405f172a) to remove the
`for` attribute, something like:
{{{#!diff
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
index 39b0aaf97b..8e2f93f09b 100644
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -188,7 +188,7 @@ class BoundField(RenderableFieldMixin):
id_ = widget.attrs.get("id") or self.auto_id
if id_:
id_for_label = widget.id_for_label(id_)
- if id_for_label:
+ if id_for_label and tag != "legend":
attrs = {**(attrs or {}), "for": id_for_label}
if self.field.required and hasattr(self.form,
"required_css_class"):
attrs = attrs or {}
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/36724#comment:7>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.