On Tuesday, June 30, 2015 at 1:29:40 PM UTC-4, Alessio Varalta wrote:
>
> 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
>

No, SQLFORM.factory returns a SQLFORM object, which inherits from FORM. 
Once created, you can add elements via server-side DOM manipulation 
<http://web2py.com/books/default/chapter/29/05/the-views#Server-side-DOM-and-parsing>,
 
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

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to