summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-06-23 06:19:26 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-06-23 06:19:26 +0000
commit553a20075e6991e7a60baee51ea68c8adc520d9a (patch)
tree3982bb54e816662bce4040e4ef62fb62922db3d6
parentfc20eeec47f1bf7b178a0432fa74f54a452b62ce (diff)
Fixed #4527 -- Changed the way errors are displayed in Form.as_p() to avoid
invalid XHTML constructs. Based on a patch from SmileyChris. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5518 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/newforms/forms.py2
-rw-r--r--tests/regressiontests/forms/tests.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py
index 6ebebded4b..1ea1c73d9a 100644
--- a/django/newforms/forms.py
+++ b/django/newforms/forms.py
@@ -159,7 +159,7 @@ class BaseForm(StrAndUnicode):
def as_p(self):
"Returns this form rendered as HTML <p>s."
- return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'<p>%s</p>', '</p>', u' %s', True)
+ return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True)
def non_field_errors(self):
"""
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
index d487ab9e8e..0808ebe97e 100644
--- a/tests/regressiontests/forms/tests.py
+++ b/tests/regressiontests/forms/tests.py
@@ -1974,11 +1974,11 @@ AttributeError: 'Person' object has no attribute 'cleaned_data'
<li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></li>
<li><ul class="errorlist"><li>This field is required.</li></ul><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /></li>
>>> print p.as_p()
-<p><ul class="errorlist"><li>This field is required.</li></ul></p>
+<ul class="errorlist"><li>This field is required.</li></ul>
<p><label for="id_first_name">First name:</label> <input type="text" name="first_name" id="id_first_name" /></p>
-<p><ul class="errorlist"><li>This field is required.</li></ul></p>
+<ul class="errorlist"><li>This field is required.</li></ul>
<p><label for="id_last_name">Last name:</label> <input type="text" name="last_name" id="id_last_name" /></p>
-<p><ul class="errorlist"><li>This field is required.</li></ul></p>
+<ul class="errorlist"><li>This field is required.</li></ul>
<p><label for="id_birthday">Birthday:</label> <input type="text" name="birthday" id="id_birthday" /></p>
If you don't pass any values to the Form's __init__(), or if you pass None,
@@ -2684,7 +2684,7 @@ its field's order in the form.
<li>Last name: <input type="text" name="last_name" value="Lennon" /></li>
<li>Birthday: <input type="text" name="birthday" value="1940-10-9" /><input type="hidden" name="hidden_text" /></li>
>>> print p.as_p()
-<p><ul class="errorlist"><li>(Hidden field hidden_text) This field is required.</li></ul></p>
+<ul class="errorlist"><li>(Hidden field hidden_text) This field is required.</li></ul>
<p>First name: <input type="text" name="first_name" value="John" /></p>
<p>Last name: <input type="text" name="last_name" value="Lennon" /></p>
<p>Birthday: <input type="text" name="birthday" value="1940-10-9" /><input type="hidden" name="hidden_text" /></p>