On 05/14/2011 06:09 PM, Greg Donald wrote:
On Sat, May 14, 2011 at 4:58 PM, Shawn Milochik <sh...@milochik.com>
wrote:
> This isn't a case of "our way rules and if you disagree then you
> suck." I just wanted to make sure you don't walk away with that
> impression.
How can I set this same widget value
name = CharField( widget=TextInput( attrs={ 'class':'myclass' } ) )
in a single place for all my CharField types?
One way:
class CustomCharField(forms.CharField):
def __init__(self, *args, **kwargs):
super(CustomCharField, self).__init__(*args, **kwargs)
self.widget=forms.TextInput(attrs={ 'class':'myclass' })
class MyForm(forms.Form):
field1 = forms.CustomCharField()
field2 = forms.CustomCharField()
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.