Add a form sqlfactory

35 views
Skip to first unread message

Alessio Varalta

unread,
Jun 30, 2015, 1:29:40 PM6/30/15
to web...@googlegroups.com
Hi, there is the possibility to add a form to sqlfactory with a for cycle..for example, i will a system where i can cycle with a for and add an element

form = SQLFORM.factory(db['element']) first time

now i will add the second element to form

Massimo Di Pierro

unread,
Jun 30, 2015, 1:49:27 PM6/30/15
to web...@googlegroups.com, alessio...@ethicalsoftware.it
I do not understand what you would like to do. Can you explain in pseudocode?

Anthony

unread,
Jun 30, 2015, 2:38:20 PM6/30/15
to web...@googlegroups.com, alessio...@ethicalsoftware.it

No, SQLFORM.factory returns a SQLFORM object, which inherits from FORM. Once created, you can add elements via server-side DOM manipulation, but not by adding a DAL Table or Field object as when calling the .factory() method. Instead, inside a loop or list comprehension, you can build up a list of DAL Tables and or Fields, and then use Python argument unpacking to pass the entire list to SQLFORM.factory. For example:

tables = [db[t] for t in ['table1', 'table2', 'table3']]
form
= SQLFORM.factory(*tables)

Anthony
Reply all
Reply to author
Forward
0 new messages