WTF表单(Flask) – FormField – FieldList,验证不起作用

WTF表单(Flask) – FormField – FieldList,验证不起作用,第1张

概述我试图使用WTF字段,FormField,FieldList创建一个ListItem表单: forms.py class WarehouseTicketItemForm(Form): description = StringField(u'Description', validators=[Required()]) quantity = IntegerField(u'Qua 我试图使用WTF字段,FormFIEld,FIEldList创建一个ListItem表单:

forms.py

class WarehouseTicketItemForm(Form):      description = StringFIEld(u'Description',valIDators=[required()])      quantity = IntegerFIEld(u'Quantity',valIDators=[required()])class WarehouseTicketForm(Form):      spot_ID = SelectFIEld(u'Spot',coerce=int)      items = FIEldList(FormFIEld(WarehouseTicketItemForm),min_entrIEs = 3)

warehouse_ticket_form.HTML

<form action="" method='POST'>  {{ form.hIDden_tag() }}  {{ form.spot_ID }} <br>  {% for item in form.items %}    {{ item }}  {% endfor %} <button type="submit" name="button">Save it</button>

warehouse_tickets.py

@coordinator.route('/warehouses/tickets/update',methods=['GET','POST'])def update_warehouses_tickets():   page = dict(title="Warehouse Ticket")   form = WarehouseTicketForm()   form.spot_ID.choices = [(s.ID,s.name)                           for s in Spot.query.filter_by(status=True)]   if form.valIDate_on_submit():       print form.data   return render_template('coordinators/warehouses/warehouse_ticket_form.HTML',page=page,form=form)

提交表单“print form.data”不会返回任何内容……

我无法弄清楚我失踪了

解决方法 我会将验证作为items字段的参数.

class WarehouseTicketForm(Form):    spot_ID = SelectFIEld(u'Spot',coerce=int)    items = FIEldList(FormFIEld(WarehouseTicketItemForm),min_entrIEs = 3,valIDators=[required()])
总结

以上是内存溢出为你收集整理的WTF表单(Flask) – FormField – FieldList,验证不起作用全部内容,希望文章能够帮你解决WTF表单(Flask) – FormField – FieldList,验证不起作用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1056382.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存