WTForms只提交第一个表单

时间:2014-09-03 05:17:16

标签: javascript python forms wtforms

我有一个博客页面,用户可以在其中添加回复,并且工作得很好。

我也有编辑功能,但它不起作用。只是第一个。

例如,当我提交第二张或第三张表格时,第一张表格总是被提交。但是当我提交第一个时,第二个提交。

以下是Jinja2 WTForms代码

{% for item in items %}    
<form method=post action="/reply/edit">      
  {{reply-form.content}}
  <input type=submit value="Submit">    
{% endfor %}

以下是调用某个路径时执行的功能(/ reply / edit)

def reply_edit():
    reply-form = Reply(request.forms)
    if reply-form.validate():
        content = reply-form.data['content']
        return content
    else:
        return 'houston, we have a problem'

基本上,在未展开时,表格会像这样布置

---------------------
|    first form     |
|                   |
---------------------
----------   --------
| delete |   | edit |
----------   --------

---------------------
|    second form    |
|                   |
---------------------
----------   --------
| delete |   | edit |
----------   --------

---------------------
|    third form     |
|                   |
---------------------
----------   --------
| delete |   | edit |
----------   --------

.........

并在展开时像这样

---------------------
|    first form     |
|                   |
---------------------
----------   ----------
| submit |   | cancel |
----------   ----------

---------------------
|    second form    |
|                   |
---------------------
----------   ----------
| submit |   | cancel |
----------   ----------

---------------------
|    third form     |
|                   |
---------------------
----------   ----------
| submit |   | cancel |
----------   ----------

.........

我从昨天开始尝试没有成功,最终拉我的头发。

这里有什么问题?

1 个答案:

答案 0 :(得分:1)

正如我在评论中提到的,form的结束标记似乎丢失了。

相关问题