List Info

Thread: maxlength is always 10 with text widget




maxlength is always 10 with text widget
country flaguser name
United States
2007-03-29 16:15:50
I have a charField in a newForm with a max_length=25, but
when I load
the form it gets set to 10 everytime.  If I get rid of the
widget,
then the max_length is set correctly at 25.   Does anyone
know why the
widget would automatically set the maxlength to a default
value?  Here
is my code:

txtfld_attrs_dict = { 'class': 'default_txt_field'}
    contact_first =
forms.CharField(widget=forms.TextInput(attrs=txtfld_attrs_di
ct),max_length=25,label=u'
Contact First')


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: maxlength is always 10 with text widget
country flaguser name
United States
2007-03-30 10:19:42
> txtfld_attrs_dict = { 'class': 'default_txt_field'}
>     contact_first =
>
forms.CharField(widget=forms.TextInput(attrs=txtfld_attrs_di
ct),max_length=25,label=u'Contact First')

I figured out the problem, you have to set the dictionary
representation within the widget parameter if you use a
variable for
the attributes.

For example:    "attrs=dict(txtfld_attrs_dict)"
instead of
"attrs=txtfld_attrs_dict"



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )