From 696910059570e5a689177fa37a1f52fa48b42cb1 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 23 Jan 2017 04:44:57 -0800 Subject: [PATCH] [1.11.x] Fixed #27761 -- Fixed quote location in multiple_input.html forms templates. Backport of 88183117c28a8d669054e9064e7bd4de19ebcd28 from master --- .../django/forms/widgets/multiple_input.html | 2 +- .../django/forms/widgets/multiple_input.html | 2 +- .../test_checkboxselectmultiple.py | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/django/forms/jinja2/django/forms/widgets/multiple_input.html b/django/forms/jinja2/django/forms/widgets/multiple_input.html index be3d449926..349db54104 100644 --- a/django/forms/jinja2/django/forms/widgets/multiple_input.html +++ b/django/forms/jinja2/django/forms/widgets/multiple_input.html @@ -1,5 +1,5 @@ {% set id = widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %} -
  • {{ group }}{% endif %}{% for widget in options %} +
  • {{ 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 60282ff887..2362aff4e6 100644 --- a/django/forms/templates/django/forms/widgets/multiple_input.html +++ b/django/forms/templates/django/forms/widgets/multiple_input.html @@ -1,5 +1,5 @@ {% with id=widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %} -
  • {{ group }}{% endif %}{% for option in options %} +
  • {{ group }}{% endif %}{% for option in options %}
  • {% include option.template_name with widget=option %}
  • {% endfor %}{% if group %} {% endif %}{% endfor %} {% endwith %} diff --git a/tests/forms_tests/widget_tests/test_checkboxselectmultiple.py b/tests/forms_tests/widget_tests/test_checkboxselectmultiple.py index a92e5533e2..6ec5c78803 100644 --- a/tests/forms_tests/widget_tests/test_checkboxselectmultiple.py +++ b/tests/forms_tests/widget_tests/test_checkboxselectmultiple.py @@ -78,6 +78,41 @@ class CheckboxSelectMultipleTest(WidgetTest): attrs={'id': 'media'}, html=html, ) + def test_nested_choices_without_id(self): + nested_choices = ( + ('unknown', 'Unknown'), + ('Audio', (('vinyl', 'Vinyl'), ('cd', 'CD'))), + ('Video', (('vhs', 'VHS'), ('dvd', 'DVD'))), + ) + html = """ +
      +
    • + +
    • +
    • Audio
        +
      • + +
      • +
      • + +
      • +
    • +
    • Video
        +
      • + +
      • +
      • + +
      • +
    • +
    + """ + self.check_html(self.widget(choices=nested_choices), 'nestchoice', ('vinyl', 'dvd'), html=html) + def test_separate_ids(self): """ Each input gets a separate ID.