WTForms - 将文本字段发布到数组
WTForms - POSTing text fields to an array
在常规 HTML 中,您可以将多个字段 POST 添加到一个数组中:
<input type="text" name="arr[]">
<input type="text" name="arr[]">
<input type="text" name="arr[]">
<input type="text" name="arr[]">
如何从 WTForms 获得此功能?基本上,我有一个表单,用户可以在其中单击小的加号和减号按钮来添加或删除表单中的字段。
您正在寻找 WTForm FieldList。它允许您创建同一字段的任意列表。
例如
emails = FieldList(StringField('email'), min_entries=1, max_entries=5)
在常规 HTML 中,您可以将多个字段 POST 添加到一个数组中:
<input type="text" name="arr[]">
<input type="text" name="arr[]">
<input type="text" name="arr[]">
<input type="text" name="arr[]">
如何从 WTForms 获得此功能?基本上,我有一个表单,用户可以在其中单击小的加号和减号按钮来添加或删除表单中的字段。
您正在寻找 WTForm FieldList。它允许您创建同一字段的任意列表。
例如
emails = FieldList(StringField('email'), min_entries=1, max_entries=5)