Answers for "handling multiple forms flask"

1

flask identify different forms on same page

if 'my_form_element_name' in request.form:
    print ('stuff')
Posted by: Guest on May-16-2020
0

handling multiple forms flask

<form>
  <input type="hidden" name="form-name" value="form1">
</form>

<form>
  <input type="hidden" name="form-name" value="form2">
</form>

def some_view():
    form1 = SomeForm()
    form2 = AnotherForm()
    if request.method == 'POST':
        form_name = request.form['form-name']
        if form_name == 'form1':
            form1.validate()
            ...
Posted by: Guest on August-17-2020

Python Answers by Framework

Browse Popular Code Answers by Language