#5847: Improvement for newforms CharField - accepting size HTML attribute
--------------------------------+-------------------------------------------
Reporter:  [EMAIL PROTECTED]  |       Owner:  nobody             
  Status:  new                  |   Component:  django.newforms    
 Version:  SVN                  |    Keywords:  newforms input size
   Stage:  Unreviewed           |   Has_patch:  0                  
--------------------------------+-------------------------------------------
 The ''newforms.fields.!CharField'' doesn't accept HTML size attribute and
 as a result during rendering all fields get the same length.
 This is also the cause for #5609.

 It would be very easy to modify it to accept it. Right now I am
 subclassing ''!CharField'' to add this functionality but it would be more
 convenient to have it in the framework.
 This is  what I'm using right now:
 {{{
 #!python
 import django.newforms as forms

 class CharField(forms.fields.CharField):
     def __init__(self, size=None, *args, **kwargs):
         self.size = size
         super(CharField, self).__init__(*args, **kwargs)

     def widget_attrs(self, widget):
         attrs = super(forms.fields.CharField, self).widget_attrs(widget)
         if self.max_length is not None and isinstance(widget,
 (forms.fields.TextInput, forms.fields.PasswordInput)):
             attrs['size'] = str(self.size)
         return attrs
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5847>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to