Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Not a valid choice" message isn't customizable in SelectField #39

Open
jace opened this issue Nov 25, 2013 · 1 comment
Open

"Not a valid choice" message isn't customizable in SelectField #39

jace opened this issue Nov 25, 2013 · 1 comment
Labels

Comments

@jace
Copy link

@jace jace commented Nov 25, 2013

SelectField and RadioField will error with "Not a valid choice" if no option is selected. This message isn't customizable, and since it's raised by the pre-validation handler, it cannot be customized via the Required() validator.

SelectField and RadioField should accept an additional parameter for this message.

@crast

This comment has been minimized.

Copy link
Contributor

@crast crast commented Feb 25, 2014

Not exactly true.

>>> class F(Form):
...   a = SelectField(choices=[('foo', 'foo')], validators=[validators.Required()])
... 
>>> form = F(a='bar')
>>> form.validate()
False
>>> form.errors
{'a': [u'Not a valid choice']}
>>> form = F(a='')
>>> form.validate()
False
>>> form.errors
{'a': [u'This field is required.']}

The Required validator can override the 'Not a valid choice', but only in the condition that the input is blank or missing.

I'm putting this ticket on hold, because there are technically ways to update the message via the message replacement system, and the SelectField is probably going to be re-written.

@crast crast added the onhold label Dec 15, 2015
@crast crast added this to the 3.1 and beyond milestone Dec 15, 2015
@davidism davidism removed this from the 3.1 and beyond milestone May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.