Get selected text from a form using wtforms SelectField

后端 未结 5 1104
别跟我提以往
别跟我提以往 2020-12-17 21:02

This is a question upon the use of wtforms SelectField.

Once the form submitted, I wish to extract selected text.

I have the following form:

5条回答
  •  情歌与酒
    2020-12-17 21:19

    Another option is to get the index from form.hour.data and call it like this:

    index = int(form.hour.data)
    form.hour.choices[index][1]
    

提交回复
热议问题