You can append i to your var name to make them unique. Otherwise
request.vars.var will always be a list since they're named the same.

for i in range(1,3):
    form[0].append(TR(INPUT(_name='var%s' % i, requires=IS_TIME())))

if form.accepts(request.vars,session):
    for i in range(1,3):
        var = request.vars['var%s' % i]
        # do something with var



On Mar 10, 3:19 pm, kachna <[email protected]> wrote:
> thanks for hint. It works fine when I send right values, but when I
> send wrong one than values in field are still lists of all values.
>
> On 10 bře, 15:09, mdipierro <[email protected]> wrote:
>
> > requires=IS_LIST_OF(IS_TIME())
>
> > On Mar 10, 4:45 am, kachna <[email protected]> wrote:
>
> > > Hi,
> > > I want to build form where user can edit or insert many records. I
> > > prepare form where are many rows of INPUT fields and this fields have
> > > same names. After send this form a receive in
> > > request.vars['INPUTs_name'] list of filled in values. It is ok. But
> > > when I use validator it don't let pass anyone value and all form
> > > fields fill in by whole list of values. Is there any trick how to make
> > > it work or different way how to get this functionality. Thanks for
> > > help.
>
> > > def sample():
> > >   form = FORM(TABLE(),INPUT(_type='submit'))
> > >   for i in range(1,3):
> > >          form[0].append(TR(INPUT(_name='var', requires=IS_TIME())))
>
> > >   if form.accepts(request.vars, session):
> > >                 response.flash = 'accepted'
> > >   elif form.errors:
> > >                 response.flash = 'form has errors'
> > >   else:
> > >                 response.flash = 'please fill the form'
>
> > >   return(dict(form=form))
>
> > > works just with IS_TIME() validator. with other one it make error. I
> > > think that is cause validators can't works with lists of values.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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.

Reply via email to