From ce249d4366a800ebc033cefb8beb33b9b0dba051 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 13 Sep 2007 23:09:40 +0000 Subject: Fixed #4752 -- Make default ErrorList customisable in newforms display. Based on a patch from michal@logix.cz and SmileyChris. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6142 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/newforms.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'docs') diff --git a/docs/newforms.txt b/docs/newforms.txt index 32c4441eb2..33625f39b8 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -554,6 +554,29 @@ method you're using::

Sender:

Cc myself:

+Customizing the error list format +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, forms use ``django.newforms.util.ErrorList`` to format validation +errors. If you'd like to use an alternate class for displaying errors, you can +pass that in at construction time:: + + >>> from django.newforms.util import ErrorList + >>> class DivErrorList(ErrorList): + ... def __unicode__(self): + ... return self.as_divs() + ... def as_divs(self): + ... if not self: return u'' + ... return u'
%s
' % ''.join([u'
%s
' % e for e in self]) + >>> f = ContactForm(data, auto_id=False, error_class=DivErrorList) + >>> f.as_p() +
This field is required.
+

Subject:

+

Message:

+
Enter a valid e-mail address.
+

Sender:

+

Cc myself:

+ More granular output ~~~~~~~~~~~~~~~~~~~~ -- cgit v1.3