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 web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to