From 0eec2a163a4b2ea4e82c53ae1d7b71bf43ac911d Mon Sep 17 00:00:00 2001 From: Kasyap Pentamaraju Date: Tue, 11 Nov 2025 14:59:28 +0530 Subject: Fixed #36724 -- Removed invalid "for" attribute on tags. --- django/forms/boundfield.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'django/forms') diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 97559fe286..5b8e7e5697 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -192,7 +192,9 @@ class BoundField(RenderableFieldMixin): if id_: id_for_label = widget.id_for_label(id_) if id_for_label: - attrs = {**(attrs or {}), "for": id_for_label} + attrs = attrs or {} + if tag != "legend": + attrs = {**attrs, "for": id_for_label} if self.field.required and hasattr(self.form, "required_css_class"): attrs = attrs or {} if "class" in attrs: -- cgit v1.3