Hello,
This is my first question on the mailing lists, so I must say that I
like web2py a lot!
I've noticed some strange behavior with the form.vars, I'll try to
explain it with a quick example here in an imaginary default.py
controller.
<code>
# defuault.py controller.
def index():
form = FORM(
INPUT(_name='field'),
INPUT(_name='field'),
INPUT(_name='field'),
INPUT(_type='submit'),
)
#####
# So pretend I entered the form with 'John Smith' in the first
input,
# 'Fred Smith' in the second input, and 'Bob Smith' in the third.
#####
if form.accepts(request.vars, session):
return len(form.vars.field)
elif form.errors:
return None
return dict(form=form)
</code>
I would expect form.vars.field to return ['John Smith', 'Fred Smith',
'Bob Smith'] but instead it returns the the representation of the list
as a string, in other words. "['John Smith', 'Fred Smith', 'Bob
Smith']". Therefore, len(form.vars.field) returns 41, whereas you
would expect it to return three.
So my question is, are you suppose to use eval(form.vars.field)
instead, or have I indeed hit on a bug, or am I just confused as to
the usage? Any help is appreciated.
Thanks,
Matt B.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---