I would like to pre-select the value for SelectField
when displaying it to user. default
argument works when it is passed at the time of instantiation but does not work once the field is initialized.
class AddressForm(Form):
country = SelectField('Country',choices=[('GB', 'Great Britan'), ('US', 'United States')], default='GB') # works
When I try to use default
value to preselect option before presenting the form to user for editing, it doesn't work.
address_form = AddressForm()
address_form.country.default='US' # doesnot work
Need a solution to set default value to pre-set values before presenting to the user.
Scenario 2: Also does not work
class AddressForm(Form):
country = SelectField('Country') # works
address_form = AddressForm()
address_form.country.choices=[('GB', 'Great Britan'), ('US', 'United States')]
address_form.country.default='US' # doesnot work