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,验证不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)