To fill the fields of the form

4 views
Skip to first unread message

Jose

unread,
Apr 14, 2009, 10:55:14 AM4/14/09
to web2py Web Framework
I must insert information to the same table from three different
SQLFORMs, as if it was a wizard.

form1 -> form2 -> form3.

In every form I force a field determined to take certain value.

Except this field the others can be the same that the previous form.

I want is to be able to fill the form with the information of the
previous one and that the user accepts or changes as believes it
suitably.

Regards
Jose

mdipierro

unread,
Apr 14, 2009, 11:18:53 AM4/14/09
to web2py Web Framework
def form1():
form=FORM(....)
if form.accepts(request.vars):
session.vars=form.vars
redirect(URL(r=request,f='form2'))
return dict(form=form)

def form2():
if not session.vars: redirect(URL(r=request,f='form1'))
form=FORM(....)
if form.accepts(request.vars):
session.vars.update(form.vars)
redirect(URL(r=request,f='form3'))
return dict(form=form)

def form3():
if not session.vars: redirect(URL(r=request,f='form1'))
form=FORM(....)
if form.accepts(request.vars):
session.vars.update(form.vars)

### do something with session.vars

redirect(URL(r=request,f='somewhere'))
return dict(form=form)

Jose

unread,
Apr 14, 2009, 11:47:18 AM4/14/09
to web2py Web Framework


On 14 abr, 15:18, mdipierro <mdipie...@cs.depaul.edu> wrote:
> def form1():
>     form=FORM(....)
>     if form.accepts(request.vars):
>          session.vars=form.vars
>          redirect(URL(r=request,f='form2'))
>     return dict(form=form)
>
> def form2():
>     if not session.vars: redirect(URL(r=request,f='form1'))
>     form=FORM(....)
>     if form.accepts(request.vars):
>          session.vars.update(form.vars)
>          redirect(URL(r=request,f='form3'))
>     return dict(form=form)
>
> def form3():
>     if not session.vars: redirect(URL(r=request,f='form1'))
>     form=FORM(....)
>     if form.accepts(request.vars):
>          session.vars.update(form.vars)
>
>          ### do something with session.vars
>
>          redirect(URL(r=request,f='somewhere'))
>     return dict(form=form)
>
Excellent Massimo.
hank you very much.

Only I fail to add this:

form=FORM(....)
form.vars = session.vars

Regards
Jose
Reply all
Reply to author
Forward
0 new messages