From a901b44c15d024a7a15ccbff5d167118427b924c Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 26 May 2007 09:02:17 +0000 Subject: [PATCH] Fixed #3718 -- Exposed form errors to cleaning methods as soon as they are available. Patch from Gary Wilson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5348 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 41d2849d62..6ebebded4b 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -174,9 +174,8 @@ class BaseForm(StrAndUnicode): Cleans all of self.data and populates self._errors and self.cleaned_data. """ - errors = ErrorDict() + self._errors = ErrorDict() if not self.is_bound: # Stop further processing. - self._errors = errors return self.cleaned_data = {} for name, field in self.fields.items(): @@ -191,16 +190,15 @@ class BaseForm(StrAndUnicode): value = getattr(self, 'clean_%s' % name)() self.cleaned_data[name] = value except ValidationError, e: - errors[name] = e.messages + self._errors[name] = e.messages if name in self.cleaned_data: del self.cleaned_data[name] try: self.cleaned_data = self.clean() except ValidationError, e: - errors[NON_FIELD_ERRORS] = e.messages - if errors: + self._errors[NON_FIELD_ERRORS] = e.messages + if self._errors: delattr(self, 'cleaned_data') - self._errors = errors def clean(self): """