Ticket #6138: error_class.diff

File error_class.diff, 1.9 KB (added by Matt Magin, 16 years ago)

Updated version - applies error_class to non_field_errors as well as the boundfield errors.

  • django/forms/formsets.py

     
    223223        try:
    224224            self.clean()
    225225        except ValidationError, e:
    226             self._non_form_errors = e.messages
     226            self._non_form_errors = self.error_class(e.messages)
    227227
    228228    def clean(self):
    229229        """
  • django/forms/forms.py

     
    136136
    137137    def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
    138138        "Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
    139         top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
     139        top_errors = self.error_class([conditional_escape(error) for error in self.non_field_errors()]) # Errors that should be displayed above all fields.
    140140        output, hidden_fields = [], []
    141141        for name, field in self.fields.items():
    142142            bf = BoundField(self, field, name)
     
    234234                    value = getattr(self, 'clean_%s' % name)()
    235235                    self.cleaned_data[name] = value
    236236            except ValidationError, e:
    237                 self._errors[name] = e.messages
     237                self._errors[name] = self.error_class(e.messages)
    238238                if name in self.cleaned_data:
    239239                    del self.cleaned_data[name]
    240240        try:
    241241            self.cleaned_data = self.clean()
    242242        except ValidationError, e:
    243             self._errors[NON_FIELD_ERRORS] = e.messages
     243            self._errors[NON_FIELD_ERRORS] = self.error_class(e.messages)
    244244        if self._errors:
    245245            delattr(self, 'cleaned_data')
    246246
Back to Top