web/formwidgets.py
branchstable
changeset 2360 1d43aa551ba9
parent 2356 ef9e30485ee7
child 2366 e4229723b824
equal deleted inserted replaced
2359:d78cf4586707 2360:1d43aa551ba9
    86 # basic html widgets ###########################################################
    86 # basic html widgets ###########################################################
    87 
    87 
    88 class TextInput(Input):
    88 class TextInput(Input):
    89     """<input type='text'>"""
    89     """<input type='text'>"""
    90     type = 'text'
    90     type = 'text'
    91 
       
    92     def render(self, form, field):
       
    93         if hasattr(field, 'max_length') and field.max_length:
       
    94             self.attrs.setdefault('size', min(45, field.max_length))
       
    95             self.attrs.setdefault('maxlength', field.max_length)
       
    96         return super(TextInput, self).render(form, field)
       
    97 
       
    98 
    91 
    99 
    92 
   100 class PasswordInput(Input):
    93 class PasswordInput(Input):
   101     """<input type='password'> and its confirmation field (using
    94     """<input type='password'> and its confirmation field (using
   102     <field's name>-confirm as name)
    95     <field's name>-confirm as name)