On Jun 29, 4:16 pm, Sebastian <[EMAIL PROTECTED]> wrote:
> Hello Django users,
>
> password = forms.CharField(label ='Password',
> required = True,
> max_length =20,
> widget =widgets.PasswordInput())
>
> Does anyone have an alternative method for dynamically specifying the
> widget of a Form.Field? I do realize this could be done in a similar
> fashion to the CSS, but I believe specifying a Django object as a
> parameter to a template filter would then violate my front-end.
>
I use newforms.form_for_model(...) to get my form classes; using them,
you can just override the widget used at any time before instantiating
the form itself:
MyFormClass.base_fields['password'].widget = widgets.PasswordInput()
It looks like you can do the same for the form itself, just substitute
your form's name for MyFormClass.
HTH,
--
M. Sylvan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---