Hi Guys, I need a hint on how to create back button in web2p y form.
def grid1(): links = [lambda row: A(SPAN(_class='icon magnifier'),'Form1',_class='button btn btn-default',_title='Form1',_href=URL("default","form1",args=[row.id]))] query=(db.test.id>0 ) grid = SQLFORM.grid(query=query,links=links) return dict(grid=grid) def form1(): form = SQLFORM.factory( Field('test',requires=IS_NOT_EMPTY()) ) form.add_button('Back',request.env.http_referer) return dict(form=form) It works fine when i click test button in grid view, i'm redirected to form1 page and when i click Back button I'm again on grid view page. However when i click Submit without providing any value in Field "test" on form1, it display error saying field can't be empty - that's where request.env.http_referer is probably updated and start to point to form1 instead of grid1. When i click Back button now, I'm still on the form1 page. Could You share some hints? Cheers! On Friday, 3 January 2014 12:56:47 UTC+1, Gael Princivalle wrote: > > Yes, that's the fastest solution. I will tried first to call a different > html page for the custom single record view page, instead of calling the > same where I have the grid. Thanks a lot. > > Il giorno domenica 29 dicembre 2013 18:28:06 UTC+1, Niphlod ha scritto: >> >> your problem is architectural: you just proved that you can't rely on the >> referrer header to make the app behave like you'd wish. >> Save the "back" url in a session variable and use that one instead ^_^ >> >> On Sunday, December 29, 2013 4:02:48 PM UTC+1, Gael Princivalle wrote: >>> >>> Goog question. >>> >>> In fact initialy referer is my previous page (http: >>> //.../default/products_listing?keywords=od), and after when the browser >>> load js and css files referer is my single view page (http: >>> //.../default/products_listing/view/products/376?keywords=od). >>> >>> I think a way to resolve it is making a different html page for the >>> single row view. Have you got any suggestion ? >>> >>> Thanks. >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.