Q:

How to add dynamically created tables to SQLFORM in web2py

I have defined counter and dict variables in controller.
I can define tables dynamically.
for x in range(0,counter+1):
    dict['%s' % x] = db.define_table('example_table_%s' % x,
        Field('example_field', type='string', ...)
        ...
        )

I can add all the created tables manually when the counter value is '2'.
form = SQLFORM.factory(
    db.some_table,
    db.another_table,
    dict['0'],
    dict['1'],
    dict['2'],
    submit_button='Submit')

How do I dynamically add all the created tables to the SQLFORM?

A:

There doesn't seem to be any need for a dictionary. Just put the tables in a list.
tables = [db.define_table('example_table_%s' % x,
                          Field('example_field', type='string', ...)
                          ...
                          )
          for x in range(0, counter+1)]

form = SQLFORM.factory(*tables)

