Do this instead:
  if form.accepts(request.vars, session):
        return len(request.vars.field)

I am not sure whether this should be considered a bug since the
process of supporting multiple fields with the same name is only
supported for checkboxes. I will look into this some more anyway.

I strongly suggest giving different names to the three INPUT fields
else you will not be able to reference them using validators (which
why this is not supported).

Massimo


On May 14, 1:02 pm, "mgbeli...@gmail.com" <mgbeli...@gmail.com> wrote:
> 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 web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to