diff --git a/django/forms/jinja2/django/forms/widgets/multiple_input.html b/django/forms/jinja2/django/forms/widgets/multiple_input.html index 349db54104..21cd9b665d 100644 --- a/django/forms/jinja2/django/forms/widgets/multiple_input.html +++ b/django/forms/jinja2/django/forms/widgets/multiple_input.html @@ -1,4 +1,4 @@ -{% set id = widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %} +{% set id = widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %}
  • {{ group }}{% endif %}{% for widget in options %}
  • {% include widget.template_name %}
  • {% endfor %}{% if group %} {% endif %}{% endfor %} diff --git a/django/forms/templates/django/forms/widgets/multiple_input.html b/django/forms/templates/django/forms/widgets/multiple_input.html index 2362aff4e6..0ba9942874 100644 --- a/django/forms/templates/django/forms/widgets/multiple_input.html +++ b/django/forms/templates/django/forms/widgets/multiple_input.html @@ -1,4 +1,4 @@ -{% with id=widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %} +{% with id=widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %}
  • {{ group }}{% endif %}{% for option in options %}
  • {% include option.template_name with widget=option %}
  • {% endfor %}{% if group %} {% endif %}{% endfor %} diff --git a/docs/releases/1.11.1.txt b/docs/releases/1.11.1.txt index d60c9e33e4..53c43443aa 100644 --- a/docs/releases/1.11.1.txt +++ b/docs/releases/1.11.1.txt @@ -36,3 +36,7 @@ Bugfixes * Allowed prefetch calls on managers with custom ``ModelIterable`` subclasses (:ticket:`28096`). + +* Restored the output of the ``class`` attribute in the ``
      `` of widgets + that use the ``multiple_input.html`` template. This fixes + ``ModelAdmin.radio_fields`` with ``admin.HORIZONTAL`` (:ticket:`28059`). diff --git a/tests/forms_tests/widget_tests/test_radioselect.py b/tests/forms_tests/widget_tests/test_radioselect.py index 58b2fc408e..8ef3a17da5 100644 --- a/tests/forms_tests/widget_tests/test_radioselect.py +++ b/tests/forms_tests/widget_tests/test_radioselect.py @@ -84,3 +84,18 @@ class RadioSelectTest(WidgetTest):
    """ self.check_html(self.widget(choices=self.beatles), 'beatle', 'J', attrs={'id': 'bar'}, html=html) + + def test_class_attrs(self): + """ + The
      in the multiple_input.html widget template include the class + attribute. + """ + html = """ +
        +
      • +
      • +
      • +
      • +
      + """ + self.check_html(self.widget(choices=self.beatles), 'beatle', 'J', attrs={'class': 'bar'}, html=html)