views:

215

answers:

1

I have a form with a ModelMultipleChoiceField and it works like a charm. However, when I set widget=forms.RadioSelect the form validation always fails with the error message "Enter a list of values."

As I said, it works perfectly well with the default widget, but not with the radio select widget. The POST request to validate the form is exactly the same, everything is exactly the same except for the widget, so I can't figure out what I'm doing wrong.

Why is this?

EDIT: Maybe I should have mentioned it works with CheckboxSelectMultiple as well.

EDIT2: It doesn't even seem to matter whether I set required=False, it still tells me to "enter a list of values."

+1  A: 

Wow, I was royally screwing up. Of course ModelMultipleChoiceField doesn't work with RadioSelect, because a list of radio buttons means that there can only be one single choice. The solution is to use ModelChoiceField.

Deniz Dogan