passing variable from view to next controller after form submit

37 views
Skip to first unread message

aetag...@gmail.com

unread,
Mar 31, 2016, 4:32:31 PM3/31/16
to web2py-users
I fill an empty array with form values in a single view, 
how am I able to pass this array into a new view so that I can do what I want with the values in the new controller after the form is submitted? 


I try doing something like the following within my controller containing the form:

if form.process().accepted:
redirect(URL('default', 'nextstep', 'vals=vals')

where vals is the array that I filled from that view, this gives me a ticket saying global variable vals is not defined when I try using it in the nextstep controller...so I am not passing it correctly.

def nextstep():
return dict(vals=vals)

P.S. This array is filled a specific way after the values are acquired from form.vars so this is why I need to figure out how to pass the new array vals into a new controller..

aetag...@gmail.com

unread,
Mar 31, 2016, 4:53:09 PM3/31/16
to web2py-users
Is it possible for me to do jquery within the controller??

So after form.process().accepted I can hide the div containing the form and show a div which will contain a button that the user can click and this way I will be able to pass the variable from the view into another controller?

I've only used javascript/jquery from within the views so I am unsure how to correctly do this. 

villas

unread,
Mar 31, 2016, 5:51:20 PM3/31/16
to web2py-users
Just try an experiment like this...

if form.process().accepted:
    myvars = {'myvar1': 'A', 'myvar2': 'B'}
    redirect(URL('default', 'nextstep', vars=myvars ))

def nextstep():  
    print request.vars.myvar1,  request.vars.myvar2
    return myvars
Reply all
Reply to author
Forward
0 new messages