Ticket #4014: textfield.diff

File textfield.diff, 1.1 KB (added by esauro@…, 11 years ago)

A modification of django.newforms.fields

  • fields.py

     
    1818    'RegexField', 'EmailField', 'URLField', 'BooleanField',
    1919    'ChoiceField', 'NullBooleanField', 'MultipleChoiceField',
    2020    'ComboField', 'MultiValueField',
    21     'SplitDateTimeField',
     21    'SplitDateTimeField','TextField'
    2222)
    2323
    2424# These values, if given to to_python(), will trigger the self.required check.
     
    8888        """
    8989        return {}
    9090
     91class TextField(Field):
     92    def __init__(self, rows=10, cols=40, *args, **kwargs):
     93        self.rows, self.cols = rows, cols
     94        super(TextField, self).__init__(widget=Textarea(attrs={'rows' : self.rows, 'cols' : self.cols}),*args, **kwargs)
     95
     96    def clean(self, value):
     97        pass
     98
     99    def widget_attrs(self, widget):
     100        if isinstance(widget, (Textarea)):
     101            return {'columns': self.cols, 'rows': self.rows}
     102
    91103class CharField(Field):
    92104    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    93105        self.max_length, self.min_length = max_length, min_length
Back to Top