I improve it a bit by making sure the only form that get submit is the desired form : form.element(_id='delete_record__row')['_class']='hidden' # To hide the "check to delete boolean" form.add_button(T('Delete'), '#', _class='btn-small btn-danger') # Add delete button delete_confirmation = T('Are you sure you want to delete this record?') form_name = request.args(0)+'/'+request.args(1) # Default form name attributed by web2py form.element('input[value='+T('Delete')+']')['_onclick'] = """if (confirm('%s')) { jQuery('#delete_record__row').removeAttr('class').removeAttr('style'); jQuery('input[type=checkbox].delete').attr('checked', 'checked'); jQuery('form').has("input[name=_formname][value='%s']").submit(); }""" % (delete_confirmation, form_name) # Attach jQueyr action to the delete button that will unhide the "check to delete" boolean and then check the checkbox and finally submit the form
Richard On Tue, Nov 13, 2012 at 7:15 PM, Richard Vézina <ml.richard.vez...@gmail.com > wrote: > Thanks for the idea Dereck > > Appreciate your help too Paolo! > > Richard > > > On Tue, Nov 13, 2012 at 6:48 PM, Derek <sp1d...@gmail.com> wrote: > >> I'd use a before_delete function to check if the checkbox 'yes im sure - >> delete' was checked. if not checked, don't delete. don't enable the delete >> button until that box is checked is another option >> >> >> On Tuesday, November 13, 2012 1:26:08 PM UTC-7, Richard wrote: >>> >>> Hello, >>> >>> I would like to replace the way web2py allow the deletion of a record. >>> Instead of the check to delete then confirm then submit... I would add a >>> delete buttton on which is attached a confirmation message onclick then >>> when the confirmation is confirmed the record is deleted. >>> >>> Actually I had this : >>> >>> form = crud.update(db.table, record) >>> form.add_button(T('Delete'), '#', _class='btn-small >>> btn-danger') >>> delete_confirmation = T('Are you sure you want to delete >>> this record?') >>> try: >>> form.element('input[value='+T(**'Delete')+']')['_onclick'] >>> = "return confirm ('%s')" % delete_confirmation >>> except: >>> pass >>> >>> What I miss is how to actually set form.deleted=true as said in the book >>> (http://web2py.com/books/**default/chapter/29/07#SQLFORM-** >>> and-insert/update/delete<http://web2py.com/books/default/chapter/29/07#SQLFORM-and-insert/update/delete> >>> )... >>> >>> I think I need a bit of JS, that detect the confirmation and will submit >>> the form. >>> >>> Am I on the right track? >>> >>> Richard >>> >>> >>> -- >> >> >> >> > > --