Well, you need some way to dynamically create names for your fields as 
well. Figure something out based on whatever you are using to construct the 
fields themselves.

On Sunday, March 30, 2014 7:45:56 PM UTC-4, horridohobbyist wrote:
>
> Treating a form like a Python list works like a charm. However, having 
> dynamically added SELECT fields, I don't know how to extract the form.vars 
> for these fields. I don't know how to assign _name in a way that I can 
> reference it after the form has been accepted. For example,
>
>         elements = []
>         for b in a:
>             sel = []
>             for c, val in a[b].iteritems():
>                 sel.append(string.capitalize(c)+':'+str(val))
>             sel.sort()
>             
> elements.append(TR(T(string.capitalize(b)),SELECT(sel,_name=???)))
>
> After a form.accepts, I need to access form.vars.??? to get the field 
> selection. But how do I know what the variable name is??
>
>
> On Saturday, 29 March 2014 09:21:59 UTC-4, Tim Richardson wrote:
>>
>> FORMs are just HTML helpers, so you manipulate them after creating them.
>> You can therefore just treat them like python lists, but there is 
>> functionality which may be more helpful:
>>
>>
>> http://web2py.com/books/default/chapter/29/05/the-views#Server-side-DOM-and-parsing
>>
>>
>>
>> On Sunday, 30 March 2014 00:11:27 UTC+11, horridohobbyist wrote:
>>>
>>> Is there a way for me to dynamically add form elements, such as INPUT 
>>> fields or SELECT fields, to a form? I'm not sure how to do this. I'd like 
>>> to add these elements only under certain conditions.
>>>
>>> Thanks.
>>>
>>>

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