Actual Behavior
>>> import wtforms
>>> class F(wtforms.Form):
... single = wtforms.SelectField(choices=[], validate_choice=False)
... multiple = wtforms.SelectMultipleField(choices=[], validate_choice=False)
>>> f = F()
>>> f.single.process_data(1)
>>> f.multiple.process_data([1])
>>> f.validate()
False
>>> f.single.errors
[]
>>> f.multiple.errors
["'1' is not a valid choice for this field"]
Expected Behavior
>>> import wtforms
>>> class F(wtforms.Form):
... single = wtforms.SelectField(choices=[], validate_choice=False)
... multiple = wtforms.SelectMultipleField(choices=[], validate_choice=False)
>>> f = F()
>>> f.single.process_data(1)
>>> f.multiple.process_data([1])
>>> f.validate()
True
>>> f.single.errors
[]
>>> f.multiple.errors
[]
The pre_validate function in the SelectMultipleField class overwrites the functionality for validate_choice present in the pre_validate function of its parent class, SelectField. Thus, the validate_choice parameter in SelectMultipleField is completely disregarded when the form's validate function is called, resulting in a wrongful validation error.
I believe this functionality should be implemented in order to add additional functionality consistency to the API.
Environment
- Python version: 3.7.6
- wtforms version: 2.3.1
Actual Behavior
Expected Behavior
The
pre_validatefunction in theSelectMultipleFieldclass overwrites the functionality forvalidate_choicepresent in thepre_validatefunction of its parent class,SelectField. Thus, thevalidate_choiceparameter inSelectMultipleFieldis completely disregarded when the form'svalidatefunction is called, resulting in a wrongful validation error.I believe this functionality should be implemented in order to add additional functionality consistency to the API.
Environment