From 584bd14dcfdee9585fec7794d53ce120ea73d0bc Mon Sep 17 00:00:00 2001 From: Gabe Jackson Date: Fri, 8 Jun 2012 15:32:35 +0200 Subject: Fixed #18134 -- BoundField.label_tag now includes the form's label_suffix There was an inconsistency between how the label_tag for forms were generated depending on which method was used: as_p, as_ul and as_table contained code to append the label_suffix where as label_tag called on a form field directly did NOT append the label_suffix. The code for appending the label_suffix has been moved in to the label_tag code of the field and the HTML generation code for as_p, as_ul and as_table now calls this code as well. This is a backwards incompatible change because users who have added the label_suffix manually in their templates may now get double label_suffix characters in their forms. --- tests/forms_tests/tests/test_forms.py | 36 ++++++++++++++--------------- tests/forms_tests/tests/test_regressions.py | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'tests/forms_tests') diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 1a3fb44a66..3b722e5ac1 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -1589,9 +1589,9 @@ class FormsTestCase(TestCase): # Recall from above that passing the "auto_id" argument to a Form gives each # field an "id" attribute. t = Template('''
-

{{ form.username.label_tag }}: {{ form.username }}

-

{{ form.password1.label_tag }}: {{ form.password1 }}

-

{{ form.password2.label_tag }}: {{ form.password2 }}

+

{{ form.username.label_tag }} {{ form.username }}

+

{{ form.password1.label_tag }} {{ form.password1 }}

+

{{ form.password2.label_tag }} {{ form.password2 }}

''') self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """
@@ -1601,18 +1601,18 @@ class FormsTestCase(TestCase):
""") self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id='id_%s')})), """
-

:

-

:

-

:

+

+

+

""") # User form.[field].help_text to output a field's help text. If the given field # does not have help text, nothing will be output. t = Template('''
-

{{ form.username.label_tag }}: {{ form.username }}
{{ form.username.help_text }}

-

{{ form.password1.label_tag }}: {{ form.password1 }}

-

{{ form.password2.label_tag }}: {{ form.password2 }}

+

{{ form.username.label_tag }} {{ form.username }}
{{ form.username.help_text }}

+

{{ form.password1.label_tag }} {{ form.password1 }}

+

{{ form.password2.label_tag }} {{ form.password2 }}

''') self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """
@@ -1819,17 +1819,17 @@ class FormsTestCase(TestCase): testcases = [ # (args, kwargs, expected) # without anything: just print the