Re: form validation for empty checkboxes that are not required (and they are the only fields present)

2010-09-28 Thread Skylar Saveland
class Asset(models.Model):
languages = models.ManyToManyField('account.Language', null=True,
blank=True)


class AssetLanguageForm(forms.ModelForm):
languages = forms.ModelMultipleChoiceField(
queryset=Language.objects.all(),
required=False,
widget=forms.CheckboxSelectMultiple
)

class Meta:
model = Asset
fields = ('languages',)


Adding a hidden garbage field works.  Seems like it's just a little
edge-case bug/gotcha.



On Sep 28, 8:49 am, Brian Neal  wrote:
> On Sep 27, 11:35 am, Skylar Saveland 
> wrote:> I have some modelforms within a .  Each form has one
> > checkboxselectmultiple that is not required.  If I post nothing (all
> > checkboxes are empty) then all of the forms are invalid.  If I post
> > anything then all of the forms are valid.  This anything could be that
> > one of the forms has a box checked, or that I add  > name='omg' value='wtf'> to the form.
>
> Can you please post your model and form code? Perhaps in a pastebin?
>
> BN

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: form validation for empty checkboxes that are not required (and they are the only fields present)

2010-09-28 Thread Brian Neal
On Sep 27, 11:35 am, Skylar Saveland 
wrote:
> I have some modelforms within a .  Each form has one
> checkboxselectmultiple that is not required.  If I post nothing (all
> checkboxes are empty) then all of the forms are invalid.  If I post
> anything then all of the forms are valid.  This anything could be that
> one of the forms has a box checked, or that I add  name='omg' value='wtf'> to the form.
>
Can you please post your model and form code? Perhaps in a pastebin?

BN

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.