Ticket #4752: div-form.diff

File div-form.diff, 1.2 KB (added by michal@…, 8 years ago)

Patch that adds a parameter to _html_output to allow using arbitrary ErrorList class implementation

  • django/newforms/forms.py

     
    110110        """
    111111        return self.prefix and ('%s-%s' % (self.prefix, field_name)) or field_name
    112112
    113     def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
     113    def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row, error_list_class = ErrorList):
    114114        "Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
    115115        top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
    116116        output, hidden_fields = [], []
    117117        for name, field in self.fields.items():
    118118            bf = BoundField(self, field, name)
    119             bf_errors = ErrorList([escape(error) for error in bf.errors]) # Escape and cache in local variable.
     119            bf_errors = error_list_class([escape(error) for error in bf.errors]) # Escape and cache in local variable.
    120120            if bf.is_hidden:
    121121                if bf_errors:
    122122                    top_errors.extend(['(Hidden field %s) %s' % (name, e) for e in bf_errors])
Back to Top