I found a good solution for me : form[0][-1][1].append(TAG.INPUT(_value='Cancel',_type="button",_onclick="window.location='%s';"%URL(r=request,f='new_contact')))
Mathias 2012/7/17 Mathias Van Daele <[email protected]>: > Thanks for your solution Richard ! > > I am still looking for a solution with a button component... > > Mathias > > 2012/7/17 Richard Vézina <[email protected]>: >> Maybe this could be enough?? >> >> {{=A(T('cancel'),_href="javascript:void(history.go(-1))")}} >> >> It will bring you back to the precedent page, in my use case, I direct the >> user on a crud.read page where the user can edit the record (crud.update). >> Then if don't want make change anymore there is a "cancel" hyperlink that >> bring back the user on the crud.read page. >> >> Richard >> >> >> On Tue, Jul 17, 2012 at 8:13 AM, Mathias <[email protected]> wrote: >>> >>> Hello, >>> >>> I have added a CANCEL button to my SQLFORM. >>> >>> Form submission prevents the correct working of it. >>> >>> I have tried to avoid form submission with this code : >>> >>> >>> def new_guest_contact(): >>> form = SQLFORM.factory(...) >>> >>> >>> form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax("%s",[],":eval");return >>> false' %URL(r=request,f='new_contact'))) >>> >>> if form.process().accepted: >>> ... >>> redirect(URL(r=request,f='new_contact_part')) >>> elif form.errors: >>> response.flash = 'form has errors' >>> else: >>> response.flash = 'Create new guest' >>> >>> return dict(form=form) >>> >>> >>> If I click the cancel button now, nothing happens anymore. >>> >>> >>> Any help is welcome. >>> >>> Thanks >>> >>> >>> Mathias >>> >>> -- >>> >>> >>> >> >> >> -- >> >> >> --

