You can do
if form.accepts(request.vars,session,keepvalues=True)
You can also simplify your code
def test():
tests = db(db.tests.owner_id==auth.user.id).select()
if tests:
form=SQLFORM(db.tests,tests[0],fields=['name'])
if form.accepts(request.vars,session):
# session.flash = '....'
redirect(URL(r=request,f="test"))
else:
form=None
return dict(form=form)
On May 6, 12:20 pm, "Sebastian E. Ovide" <[email protected]>
wrote:
> Hi All,
>
> in an action that updates a FORM , when the form accepts the new values, it
> updates the DB correctly, but when redraw the page it display the old
> values. If I press Submit again (keeping the old values in the form) it
> displays the new values entered previously... and so on for ever....
>
> the work around was to add a redirect to the same controller just after the
> db.update.
>
> Is it the correct way to deal with custom FORMS ? Am I missing something ?
>
> thanks
>
> def test():
> form = None
> # find tests profile of current user
> query=db.tests.owner_id==auth.user.id
> tests = db(query).select()
> if len(tests)>0:
> #get the first found
> test=tests[0]
>
> form=FORM(TABLE(TR("Name:",INPUT(_type="text",_name="name",value=
> test.name,requires=IS_NOT_EMPTY())),
> TR("",INPUT(_type="submit",_value="SUBMIT"))
> ))
>
> if form.accepts(request.vars,session):
> db(query).update(name=form.vars.name)
> # HERE THE REDIRECT !!!!!!
> redirect(URL(r=request,f="test"))
>
> return dict(form=form)
>
> ----------------------------
> Sebastian E. Ovide
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---