Yes that what I am doing right now... I generate the form with SQLFORM.factory and then in the view as you and Anthony suggest I "refact" my form to get what I want.
I am pretty impress by this new feature, I was not aware about custom form. It seems exactly what I was searching for... Thanks. Richard On Thu, Jun 28, 2012 at 1:15 PM, [email protected] < [email protected]> wrote: > Richard, wouldn't be better organizing your form direct in HTML using > custom.form tags? > > > > On 06/28/2012 01:00 PM, Richard Vézina wrote: > >> Forget the precedent email... I think I found how, it didn't work the >> first time I try, so I just put everything into string, maybe I had >> problem with a comma... >> >> inputs_list = [] >> for a in field1_names_dict: >> >> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f1', >> type='boolean', widget=SQLFORM.widgets.**checkboxes.widget, >> requires=IS_EMPTY_OR(IS_IN_**SET([assay_names_dict[a]['** >> field1_name_ui']])))) >> >> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f2', >> db.ref_tab1, requires = >> IS_EMPTY_OR(IS_IN_DB(db,'ref_**tab1.id<http://ref_tab1.id> >> <http://ref_tab1.id>','%(**REPRESENTFIELD)s')))) >> >> >> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f3', >> db.ref_tab2, requires = >> IS_EMPTY_OR(IS_IN_DB(db,'ref_**tab2.id<http://ref_tab2.id> >> <http://ref_tab2.id>','%(**REPRESENTFIELD)s')))) >> >> >> I I just have to add the formstyle in the SQLFORM.factory call : >> >> form = SQLFORM.factory(*inputs_list, formstyle='divs') >> >> On Thu, Jun 28, 2012 at 11:47 AM, Richard Vézina >> <[email protected] >> <mailto:ml.richard.vezina@**gmail.com<[email protected]>>> >> wrote: >> >> Hello Anthony, >> >> If I don't use eval(), should I use web2py dummy table, I don't see >> how I will be able to build dummy table dynamically and declare it >> as inputs_list to be use with the asterisk... If I just put a >> asterisk in front of my actual generated inputs_list it not working >> since the item in the list are text. I don't see how I can insert >> Field into the list without generating them as strings... >> >> I will read a bit the links you sent. >> >> Thanks. >> >> Richard >> >> >> On Thu, Jun 28, 2012 at 11:29 AM, Anthony <[email protected] >> <mailto:[email protected]>> wrote: >> >> I wounder what should be the best way to alter a form >> generated by SQLFORM.factory in a way where fields will be >> placed into a html table a 3 columns. >> >> So each 3 fields I need to insert a "tr" and each field need >> to be in a "td"... >> >> >> You might want to create a custom form layout in the view: >> >> http://web2py.com/books/**default/chapter/29/7#Custom-**forms<http://web2py.com/books/default/chapter/29/7#Custom-forms>. >> That >> way you can still use SQLFORM.factory to handle all the widget >> creation and processing, but you can present the fields however >> you want. You might also check out plugin_solidform >> >> <http://dev.s-cubism.com/**plugin_solidform<http://dev.s-cubism.com/plugin_solidform> >> >. >> >> >> formstring = "SQLFORM.factory(" +','.join(inputs_list)+")" >> >> form = eval(formstring) >> >> >> No need to eval code like that in Python. If you have a list of >> objects you want to submit as separate args to a function, just >> precede the list with an asterisk: >> >> | >> form =SQLFORM.factory(*input_list) >> | >> >> In that case, you can change the way you define the Field items >> in the list -- make them actual Field() objects rather than just >> strings of code. >> >> Note, for keyword arguments, you can submit a dictionary >> preceded by two asterisks: >> >> | >> some_function(**some_**dictionary) >> | >> >> Anthony >> >> >> >> >

