Ticket #17533: boundfield.patch

File boundfield.patch, 1.6 KB (added by freyley, 13 years ago)

Or better, set it as a class variable

  • .py

    old new  
    6969    # class is different than Form. See the comments by the Form class for more
    7070    # information. Any improvements to the form API should be made to *this*
    7171    # class, not to the Form class.
     72    _bound_field_class = BoundField
    7273    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
    7374                 initial=None, error_class=ErrorList, label_suffix=':',
    7475                 empty_permitted=False):
     
    9697
    9798    def __iter__(self):
    9899        for name, field in self.fields.items():
    99             yield BoundField(self, field, name)
     100            yield self._bound_field_class(self, field, name)
    100101
    101102    def __getitem__(self, name):
    102103        "Returns a BoundField with the given name."
     
    104105            field = self.fields[name]
    105106        except KeyError:
    106107            raise KeyError('Key %r not found in Form' % name)
    107         return BoundField(self, field, name)
     108        return self._bound_field_class(self, field, name)
    108109
    109110    def _get_errors(self):
    110111        "Returns an ErrorDict for the data provided for the form"
     
    142143
    143144        for name, field in self.fields.items():
    144145            html_class_attr = ''
    145             bf = BoundField(self, field, name)
     146            bf = self._bound_field_class(self, field, name)
    146147            bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable.
    147148            if bf.is_hidden:
    148149                if bf_errors:
Back to Top