Thanks weheh, that helped a lot!

On Aug 14, 12:12 am, weheh <[email protected]> wrote:
> Each form needs to have a unique name. I suppose you could use uuid to
> make a unique name. Then something like this pseudocode  might work:
>
> allforms=dict(form_id=new_form_id(),form=SQLFORM(...))
> for f in allforms:
>     if f['form'].accepts(request.vars,formname=f['form_id']):
>         # do something if form accepts
>     else:
>         # do something else if form doesn't accept
> return dict(allforms=allforms)
>
> Then in views you will need to loop on allforms to make your form. You
> will probably want a custom form and make sure you have a hidden input
> with id=f['form_id']
>
> Obviously, if the order of forms is important, you will want to modify
> this code to make the forms into a list instead of a dict.
>
> Hope this helps. Good luck.
>
> On Aug 13, 9:24 pm, Karthik <[email protected]> wrote:
>
>
>
>
>
>
>
> > Is there a way to dynamically name the forms?
> > I don't know how many forms I'll need to display, it depends on an
> > external factor.
> > (I have a textarea and depending on the lines filled in the textarea
> > by the user, I need to create that many forms).
>
> > Is this possible withing web2py's FORM() helper or would using the
> > default HTML be a better idea?
>
> > Thanks!
>
> > On May 6 2010, 9:17 am, mdipierro <[email protected]> wrote:
>
> > > If you have two forms you have to name them:
>
> > > if form_back.accepts(request.vars, session, formname='back'):
> > > ...
> > > if form_membership.accepts(request.vars,
> > > session,formname='membership'):
>
> > > On May 6, 7:19 am, Sverre <[email protected]> wrote:
>
> > > > I'm using this design  in a controller to have buttons on the page:
> > > > ----
> > > >     form_membership = FORM('', INPUT(_type='submit',_value='New'))
> > > >     form_back = FORM('', INPUT(_type='submit',_value='Back to user'))
> > > >     if form_back.accepts(request.vars, session):
>
> > > > redirect(URL(r=request,c='sysuser',f='edit_user',args=userid))
> > > >     if form_membership.accepts(request.vars, session):
>
> > > > redirect(URL(r=request,c='sysuser',f='new_membership',args=userid))
> > > >     return
> > > > dict(msg=rows,form_membership=form_membership,form_back=form_back)
> > > > ----
> > > > But this isn't working. I'm don't get the right redirections. The
> > > > "Back to user' button gives me the redirection of the other button.
> > > > Has someone a clue?

Reply via email to