This is a question upon the use of wtforms SelectField.
wtforms SelectField
Once the form submitted, I wish to extract selected text.
I have the following form:
Define choices global in forms:
HOUR_CHOICES = [('1', '8am'), ('2', '10am')] class TestForm(Form): hour = SelectField(u'Hour', choices=HOUR_CHOICES)
import it from forms, convert it to dict:
from .forms import HOUR_CHOICES hour_display = dict(HOUR_CHOICES).get(form.hour.data)