Try this:
credentials =
forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
choices=Truckshare.CREDENTIALS_CHOICES)
On Dec 17, 9:14 pm, "Alex Ezell" <[EMAIL PROTECTED]> wrote:
> I have several fields define in my models like this:
> CREDENTIALS_CHOICES = (
> ('LM', "Commercial Driver's License"),
> ('IN', 'Insured'),
> ('DR', 'DOT Registered (Interstate)'),
> ('FI', 'Fragile Item Qualified'),
> )
> credentials = models.CharField(max_length=2, blank=True,
> choices=CREDENTIALS_CHOICES)
>
> Then, I have them described in my form class as this:
>
> credentials = forms.ChoiceField(choices=Truckshare.CREDENTIALS_CHOICES)
>
> What I would like to do is use a CheckboxSelectMultiple for this field.
> However, when I do that like this:
>
> credentials = forms.ChoiceField(choices=Truckshare.CREDENTIALS_CHOICES
> ,widget=CheckboxSelectMultiple)
>
> but that will fail because it will submit multiple values to the model and
> since it's ChoiceField, it will complain.
>
> How can I set this up so that I can use choices in my model and use a
> CheckboxSelectMultiple field via newforms?
>
> Thanks!
>
> /alex
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---