Opened 3 years ago

Last modified 3 years ago

#33042 closed Cleanup/optimization

Form validator cannot pass ModelMultipleChoiceField by checkbox — at Initial Version

Reported by: cloudy-sfu Owned by: nobody
Component: Forms Version: 3.2
Severity: Normal Keywords: form, validator, widget
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the form, I set:

fill_na_avg = forms.ModelMultipleChoiceField(Column.objects.all(), widget=forms.HiddenInput(), required=False)

In the HTML file, I write a group of :

<input type="checkbox" name="fill_na_avg" value="{{ column.id }}">

After submitting the POST, there is:

<QueryDict: {'fill_na_avg': ['41', '42', '43']}>

It seems normal but when checking it by the "is_valid" function, it reports:

fill_na_avg
Enter a list of values.

If I replace the sentence in form class by

fill_na_avg = forms.ModelMultipleChoiceField(Column.objects.all(), widget=forms.CheckboxInput(), required=False)

It works.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top