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

validate_on_submit() expects a tuple list for SelectField even though a normal list is a valid argument #417

Closed
ghost opened this issue Jul 29, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 29, 2020

Actual Behavior

form.validate on submit() evaluates to False when choices in SelectField is a list of values only. The same form validation evaluates to True when using (value, label) tuples as used with version 2.2.1

class RegistrationForm(FlaskForm):

    language = SelectField('Language', choices=['python', 'ruby', 'rust'], validators=[DataRequired()])
    submit = SubmitField('Submit')


@app.route('/', methods=['GET', 'POST'])
def index():
    form = RegistrationForm()
    if form.validate_on_submit():
        return redirect(url_for('test'))
    return render_template('index.html', form=form)

The SelectField() is rendered properly in the HTML form and its value can be accessed with form.language.data but form.validate_on_submit() still evaluates to False.

Expected Behavior

form.validate on submit() to evaluate to True when choices in SelectField is a list of values only as well.

Environment

  • Python version: 3.8.2
  • Flask-wtf version: 0.14.3
  • wtforms version: 2.3.1
@davidism
Copy link
Member

davidism commented Jul 29, 2020

Duplicate of pallets-eco/wtforms#598

@azmeuk Need to backport that to the 2.x branch and make a bugfix release.

@davidism davidism marked this as a duplicate of pallets-eco/wtforms#598 Jul 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant