Search code examples
pythonweb2py

Iterate through submitted sqlform fields and values in web2py


Here is my code:

def index():

    form = SQLFORM(db.sometable)

    if form.process().accepted:
        response.flash = 'your data is posted'

In above code, I just want that when the form is submitted, I should be able to iterate through its fields(inputs) and corresponding values. So how do I do it?


Solution

  • Once the form has been accepted, form.vars is a Storage object (basically a dict) of the fields' values.