From 584bd14dcfdee9585fec7794d53ce120ea73d0bc Mon Sep 17 00:00:00 2001 From: Gabe Jackson Date: Fri, 8 Jun 2012 15:32:35 +0200 Subject: [PATCH] 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. --- django/forms/forms.py | 9 +++--- docs/ref/forms/api.txt | 9 +++++- docs/releases/1.6.txt | 31 ++++++++++++++++++ docs/topics/forms/index.txt | 16 ++++++--- docs/topics/forms/modelforms.txt | 2 +- tests/admin_util/tests.py | 4 +-- tests/forms_tests/tests/test_forms.py | 36 ++++++++++----------- tests/forms_tests/tests/test_regressions.py | 4 +-- 8 files changed, 77 insertions(+), 34 deletions(-) diff --git a/django/forms/forms.py b/django/forms/forms.py index 0c598ac7751..e6a11f28fba 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -170,11 +170,6 @@ class BaseForm(object): if bf.label: label = conditional_escape(force_text(bf.label)) - # Only add the suffix if the label does not end in - # punctuation. - if self.label_suffix: - if label[-1] not in ':?.!': - label = format_html('{0}{1}', label, self.label_suffix) label = bf.label_tag(label) or '' else: label = '' @@ -522,6 +517,10 @@ class BoundField(object): If attrs are given, they're used as HTML attributes on the