diff options
| author | Tim Graham <timograham@gmail.com> | 2018-03-14 11:28:18 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-03-15 09:10:23 -0400 |
| commit | 87dc0844a634360182bcb74d491508111ef8a652 (patch) | |
| tree | 072b28c846356970202d7dd06a3c845b55ed24cb /django/forms | |
| parent | fb8fd535c0f47cffb4da0c5900f3f66e1ec8d432 (diff) | |
Fixed #29200 -- Fixed label rendering when using RadioSelect and CheckboxSelectMultiple with MultiWidget.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/boundfield.py | 2 | ||||
| -rw-r--r-- | django/forms/jinja2/django/forms/widgets/input_option.html | 2 | ||||
| -rw-r--r-- | django/forms/templates/django/forms/widgets/input_option.html | 2 | ||||
| -rw-r--r-- | django/forms/widgets.py | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index d0ddd9715b..7f40fbbbb4 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -248,7 +248,7 @@ class BoundWidget: return self.tag(wrap_label=True) def tag(self, wrap_label=False): - context = {'widget': self.data, 'wrap_label': wrap_label} + context = {'widget': {**self.data, 'wrap_label': wrap_label}} return self.parent_widget._render(self.template_name, context, self.renderer) @property diff --git a/django/forms/jinja2/django/forms/widgets/input_option.html b/django/forms/jinja2/django/forms/widgets/input_option.html index 3f7085a4f0..48cd65b93a 100644 --- a/django/forms/jinja2/django/forms/widgets/input_option.html +++ b/django/forms/jinja2/django/forms/widgets/input_option.html @@ -1 +1 @@ -{% if wrap_label %}<label{% if widget.attrs.id %} for="{{ widget.attrs.id }}"{% endif %}>{% endif %}{% include "django/forms/widgets/input.html" %}{% if wrap_label %} {{ widget.label }}</label>{% endif %} +{% if widget.wrap_label %}<label{% if widget.attrs.id %} for="{{ widget.attrs.id }}"{% endif %}>{% endif %}{% include "django/forms/widgets/input.html" %}{% if widget.wrap_label %} {{ widget.label }}</label>{% endif %} diff --git a/django/forms/templates/django/forms/widgets/input_option.html b/django/forms/templates/django/forms/widgets/input_option.html index 3f7085a4f0..48cd65b93a 100644 --- a/django/forms/templates/django/forms/widgets/input_option.html +++ b/django/forms/templates/django/forms/widgets/input_option.html @@ -1 +1 @@ -{% if wrap_label %}<label{% if widget.attrs.id %} for="{{ widget.attrs.id }}"{% endif %}>{% endif %}{% include "django/forms/widgets/input.html" %}{% if wrap_label %} {{ widget.label }}</label>{% endif %} +{% if widget.wrap_label %}<label{% if widget.attrs.id %} for="{{ widget.attrs.id }}"{% endif %}>{% endif %}{% include "django/forms/widgets/input.html" %}{% if widget.wrap_label %} {{ widget.label }}</label>{% endif %} diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 50e41b59ec..566bdf25d6 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -621,12 +621,12 @@ class ChoiceWidget(Widget): 'attrs': option_attrs, 'type': self.input_type, 'template_name': self.option_template_name, + 'wrap_label': True, } def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) context['widget']['optgroups'] = self.optgroups(name, context['widget']['value'], attrs) - context['wrap_label'] = True return context def id_for_label(self, id_, index='0'): |
