summaryrefslogtreecommitdiff
path: root/django/forms/boundfield.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms/boundfield.py')
-rw-r--r--django/forms/boundfield.py4
1 files changed, 3 insertions, 1 deletions
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: