平台:如何使用具有动态选择值的选择字段来生成空白值 [英] Wtforms: How to generate blank value using select fields with dynamic choice values

查看:137
本文介绍了平台:如何使用具有动态选择值的选择字段来生成空白值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Flask 与WTForms( doc )。什么是最好的方式来产生一个空字段的选择字段?

  form.group_id.choices = [( g.key().id(),g.name)用于Group.all()中的g.order('name')] 

有没有像表单字段blank = True?
$ b $ pre $ my $ c $ myfield = wtf .SelectField()


解决方案

($,$,$,$,$,$,$,$,$,


I'm using Flask with WTForms (doc) on Google App Engine. What is the best way to generate an field with an empty value for a select field?

form.group_id.choices = [(g.key().id(), g.name) for g in Group.all().order('name')]

Is there something like "blank=True" for the form field?

myfield = wtf.SelectField()

解决方案

Can you just prepend an empty pair to the list?

form.group_id.choices.insert(0, ('', ''))

这篇关于平台:如何使用具有动态选择值的选择字段来生成空白值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆