[英]wtform selectfield validation not to choose the first in the list
我有兩個選擇字段,用戶應該從列表中選擇一個機場,但是我希望第一個選項是“做出您的選擇”或類似的東西,並且用戶將無法選擇(例如默認選擇)
AIR_PORTS_LIST = [(0, 'Make Your Choice'), (1, 'praia'), (2, 'abidjan')]
class LoginForm(FlaskForm):
airport_src = SelectField('AirPort Source', choices=AIR_PORTS_LIST, validators=[DataRequired()])
airport_dst = SelectField('AirPort Destination', choices=AIR_PORTS_LIST, validators=[DataRequired()])
它被稱為占位符,是的,您可以像這樣用 html 編寫:
{{ form.airport_src(placeholder='Make Your Choice') }}
{{ form.airport_dst(placeholder='Make Your Choice') }}
沒有必要寫在選擇中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.