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]> 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. 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>.
>
>     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
>

Reply via email to