1

I can't understand exactly how to handle several forms submit for this particular case. I am using Flask and wtforms, let me give an example:

views.py

from forms import EditForm

@app.route('/forms')
def edit(self):
    form = EditForm(request.form, obj=some_obj)
    form_1 = EditForm(request.form_1, obj=some_other_ocj)

    if request.method == 'POST' and form.validate():
        form.save()

    if request.method == 'POST' and form_1.validate():
        form_1.save()

forms.py

from wtforms import *

class EditForm(Form):
    language = StringField()
    text = StringField()

This is a very limited example, but the first thing that errors is that the request object on the view does not have a form_1 attribute.

PepperoniPizza
  • 8,842
  • 9
  • 58
  • 100
  • 2
    `request.form` contains the POST data that was submitted. The name doesn't change based on the name of the variable you used. – dirn Sep 16 '14 at 11:17
  • Do you have multiple instances of the *field sets* that make up an `EditForm` inside one form or do you have multiple distinct `
    ` tags on the page and you need to distinguish between them?
    – Sean Vieira Sep 16 '14 at 15:11
  • @SeanVieira I have different
    tags and I want to distinguish between them in the view process Form.
    – PepperoniPizza Sep 16 '14 at 15:42
  • All right - I've marked this a duplicate of http://stackoverflow.com/questions/21949452/wtforms-two-forms-on-the-same-page - if this doesn't answer your use case, please clarify your question and I'll re-open. – Sean Vieira Sep 16 '14 at 16:36

0 Answers0