Re: [web2py] Re: Dynamically Creating a Form

2014-03-31 Thread horridohobbyist
Wow, thanks! Python is pretty amazing. (I come from a largely C background.)


On Monday, 31 March 2014 01:06:11 UTC-4, Anthony wrote:

 Yes, that will do it. form.vars (as well as request.vars and many other 
 web2py objects) is a gluon.storage.Storage object, which is much like a 
 dictionary and allows dictionary-like syntax for accessing items. Similar 
 syntax works with DAL Table and Row objects.

 Anthony

 On Monday, March 31, 2014 12:49:37 AM UTC-4, mweissen wrote:

 Try form.vars['color'] or take a variable v
 v=color
 form.vars[v]




 2014-03-31 2:32 GMT+02:00 horridohobbyist horrido...@gmail.comjavascript:
 :

 But if I create a name such as, for example, color, I'd need to access 
 the form variable thusly:  form.vars.color. Since the name was created on 
 the fly, how can I actually say form.vars.color?? If the name was created 
 and stored in a variable, say, x, I can't say form.vars.x. I guess I 
 don't quite understand Python's capabilities.


 On Sunday, 30 March 2014 20:00:56 UTC-4, Anthony wrote:

 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+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.



  

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


[web2py] Re: Dynamically Creating a Form

2014-03-30 Thread horridohobbyist
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.


[web2py] Re: Dynamically Creating a Form

2014-03-30 Thread Anthony
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.


[web2py] Re: Dynamically Creating a Form

2014-03-30 Thread horridohobbyist
But if I create a name such as, for example, color, I'd need to access 
the form variable thusly:  form.vars.color. Since the name was created on 
the fly, how can I actually say form.vars.color?? If the name was created 
and stored in a variable, say, x, I can't say form.vars.x. I guess I 
don't quite understand Python's capabilities.


On Sunday, 30 March 2014 20:00:56 UTC-4, Anthony wrote:

 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.


Re: [web2py] Re: Dynamically Creating a Form

2014-03-30 Thread Martin Weissenboeck
Try form.vars['color'] or take a variable v
v=color
form.vars[v]




2014-03-31 2:32 GMT+02:00 horridohobbyist horrido.hobb...@gmail.com:

 But if I create a name such as, for example, color, I'd need to access
 the form variable thusly:  form.vars.color. Since the name was created on
 the fly, how can I actually say form.vars.color?? If the name was created
 and stored in a variable, say, x, I can't say form.vars.x. I guess I
 don't quite understand Python's capabilities.


 On Sunday, 30 March 2014 20:00:56 UTC-4, Anthony wrote:

 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.


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


Re: [web2py] Re: Dynamically Creating a Form

2014-03-30 Thread Anthony
Yes, that will do it. form.vars (as well as request.vars and many other 
web2py objects) is a gluon.storage.Storage object, which is much like a 
dictionary and allows dictionary-like syntax for accessing items. Similar 
syntax works with DAL Table and Row objects.

Anthony

On Monday, March 31, 2014 12:49:37 AM UTC-4, mweissen wrote:

 Try form.vars['color'] or take a variable v
 v=color
 form.vars[v]




 2014-03-31 2:32 GMT+02:00 horridohobbyist horrido.hobb...@gmail.com:

 But if I create a name such as, for example, color, I'd need to access 
 the form variable thusly:  form.vars.color. Since the name was created on 
 the fly, how can I actually say form.vars.color?? If the name was created 
 and stored in a variable, say, x, I can't say form.vars.x. I guess I 
 don't quite understand Python's capabilities.


 On Sunday, 30 March 2014 20:00:56 UTC-4, Anthony wrote:

 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.



  

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


[web2py] Re: Dynamically Creating a Form

2014-03-29 Thread Tim Richardson
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.