When attempting to set the default value of a SelectField with WTForms, I pass in value to the \'default\' parameter like so.
class TestForm(Form):
test_fi
This is a choices
settings with SelectField
when you use an int
, it works like this:
test_select = SelectField("Test", coerce=int, choices=[(0, "test0"), (1, "test1")], default=1)
or:
class TestForm(Form):
test_select = SelectField("Test", coerce=int)
@app.route("/test")
def view_function():
form = TestForm()
form.test_select.choices = [(0, "test0"), (1, "test1")]
form.test_select.default = 1
form.process()