On Tuesday, September 26, 2017 at 6:00:27 PM UTC-7, Tiago Barrionuevo wrote: > > Hi! > I'm trying to use custom forms for the actions used internally by the > SQLFORM.grid and that are called by the grid links. > I got all that working but now I need to do my own data manipulation after > the grid processes and accepts the form. However if I call > "mygrid.update_form.accepted" nothing happens and it's because the grid's > internal do the redirect after the update_form processing! > This preclude any form post processing outside the grid. > > Wouldn't you use the onvalidation() method? Look at <URL: http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-signature> and there's an example just a short scroll down.
/dps > After a lot of research I developed the follow method to work with > SQLFORM.grid and custom forms: > > controller action: facilities_list() > > grid = SQLFORM.grid(query, args=request.args[:2], field_id= > db.facility.id, formname='grid_facilities') > > if 'edit' in request.args: > form = grid.update_form > > if form.accepted: > ### custom processing here ### > session.flash = 'Facility updated!' > redirect(URL(request.controller, 'list')) > > response.view = '%s/facility_edit.%s' % (request.controller, > request.extension) > return dict(item_name=db.facility._singular, form=form) > > return dict(item_name=db.facility._singular, grid=grid) > > > > However the code inside the block "if grid.update_form.accepted:" is never > executed because what I explain above. > > The only solution a found was change the SQLFORM.grid code to accepts one > more parameter "custom_form=False" (defaults to false) and in the case it's > True (when using custom forms) it don't redirects to the referrer and > return normally and so I can test the updated_form.accepted, do my custom > processing and redirect by myself. > > Another important behavior would be make available the referrer in the > grid for external access like this: > > if grid.update_form.accepted: > ### custom processing here ### > session.flash = 'Facility updated!' > redirect(grid.referrer) > > I apologize if already there is a possible solution for this! > Thanks in advance. > > -- 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.