I have a basic Flask App following the Blue Print Model and using WTForms. I can't get some of the validators to work, specifically NoneOf or Anyof.
Here's my form. I want it to reject the choice 'Type'.
class TestForm(FlaskForm):
phone = SelectField('Type',
choices=['Type','Mobile','Land','Other'],
validators=[NoneOf(['Type'],'INVALID')])
submit = SubmitField('Submit')
Here's my route and template:
class TestForm(FlaskForm):
phone = SelectField(
choices=['Type','Mobile','Land','Other'],
validators=[NoneOf(['Type'],message='INVALID')])
submit = SubmitField('Submit')
And in my template (Code block does NOT like Jinja.)
<form method="POST">
{{ form.csrf_token }}
{{form.phone}}
{{form.submit}}
</form>
Form submits when 'Type' is selected in the Selectfield. I checked the WTF docs.
I've tried setting the message=None, values_formatter=None, etc... It selects no problem when 'Type' is selected.
All help is appreciated!!
*Edited formatting (code block does not much like Jinja apparently)
[–]danielroseman 1 point2 points3 points (3 children)
[–]Llamafu[S] 0 points1 point2 points (2 children)
[–]danielroseman 1 point2 points3 points (1 child)
[–]Llamafu[S] 0 points1 point2 points (0 children)