Ticket #5992: errorlist.patch
File errorlist.patch, 1.8 KB (added by , 17 years ago) |
---|
-
django/newforms/forms.py
46 46 # class is different than Form. See the comments by the Form class for more 47 47 # information. Any improvements to the form API should be made to *this* 48 48 # class, not to the Form class. 49 50 error_class = ErrorList 51 49 52 def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 50 initial=None, error_class= ErrorList, label_suffix=':'):53 initial=None, error_class=None, label_suffix=':'): 51 54 self.is_bound = data is not None or files is not None 52 55 self.data = data or {} 53 56 self.files = files or {} 54 57 self.auto_id = auto_id 55 58 self.prefix = prefix 56 59 self.initial = initial or {} 57 self.error_class = error_class 60 self.error_class = error_class or self.error_class or ErrorList 58 61 self.label_suffix = label_suffix 59 62 self._errors = None # Stores the errors after clean() has been called. 60 63 … … 188 191 value = getattr(self, 'clean_%s' % name)() 189 192 self.cleaned_data[name] = value 190 193 except ValidationError, e: 191 self._errors[name] = e.messages194 self._errors[name] = self.error_class(e.messages) 192 195 if name in self.cleaned_data: 193 196 del self.cleaned_data[name] 194 197 try: 195 198 self.cleaned_data = self.clean() 196 199 except ValidationError, e: 197 self._errors[NON_FIELD_ERRORS] = e.messages200 self._errors[NON_FIELD_ERRORS] = self.error_class(e.messages) 198 201 if self._errors: 199 202 delattr(self, 'cleaned_data') 200 203