简体   繁体   English

如何在烧瓶 wtf 中创建下拉字段

[英]how to create drop down field in flask wtf

i want to create drop down menu's using flask wtforms.我想使用flask wtforms创建下拉菜单。 i have found drop down's in bootstrap 4 but i am unable to use it.我在 bootstrap 4 中找到了下拉菜单,但我无法使用它。 i want to make it using flask wtf.我想用flask wtf来制作它。 here's what i want to achieve:这是我想要实现的目标:

 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/> <form class="" action="index.html" method="post"> <div class="form-group"> <label for="exampleFormControlSelect1">Example select</label> <select class="form-control" id="exampleFormControlSelect1"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </div> </form>

wtforms offers the SelectField wtforms提供SelectField

see docs https://wtforms.readthedocs.io/en/2.3.x/fields/#wtforms.fields.SelectField见文档https://wtforms.readthedocs.io/en/2.3.x/fields/#wtforms.fields.SelectField

Example (from the docs)示例(来自文档)

class PastebinEntry(Form):
    language = SelectField(u'Programming Language', choices=[('cpp', 'C++'), ('py', 'Python'), ('text', 'Plain Text')])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM