I have a form with a choice field that is using CheckboxSelectMultiple widget:
foo = forms.ChoiceField(widget=forms.CheckboxSelectMultiple, choices=( ("1", "ONE"), ("2", "TWO"), ))
The form renders fine showing two checkboxes, however it doesn't validate.
If I select both checkboxes I am getting an error: Select a valid choice. [u'1', u'2'] is not one of the available choices
Selecting one checkbox doesn't work either, it gives me: Select a valid choice. [u'1'] is not one of the available choices.
What's going on here?
If you make the field a forms.MultipleChoiceField rather than a forms.ChoiceField it will work better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With