# HG changeset patch # User Katia Saurfelt # Date 1242726535 -7200 # Node ID 4ceaf8f2709bfbdc9ec739f30f437715a4eb3814 # Parent 9a02979a2c00fdb52232c3025c0d0e23453d694c add onfailure fonction for validateForm, return formid on success diff -r 9a02979a2c00 -r 4ceaf8f2709b web/data/cubicweb.edition.js --- a/web/data/cubicweb.edition.js Tue May 19 11:44:06 2009 +0200 +++ b/web/data/cubicweb.edition.js Tue May 19 11:48:55 2009 +0200 @@ -342,11 +342,11 @@ } -function handleFormValidationResponse(formid, onsuccess, result) { +function handleFormValidationResponse(formid, onsuccess, onfailure, result) { // Success if (result[0]) { if (onsuccess) { - return onsuccess(result[1]); + return onsuccess(result[1], formid); } else { document.location.href = result[1]; return ; @@ -365,6 +365,9 @@ _displayValidationerrors(formid, descr[0], descr[1]); updateMessage(_("please correct errors below")); document.location.hash = '#header'; + if (onfailure){ + onfailure(formid); + } return false; } @@ -426,7 +429,7 @@ * to the appropriate URL. Otherwise, the validation errors are displayed * around the corresponding input fields. */ -function validateForm(formid, action, onsuccess) { +function validateForm(formid, action, onsuccess, onfailure) { try { var zipped = formContents(formid); var d = asyncRemoteExec('validate_form', action, zipped[0], zipped[1]); @@ -435,7 +438,7 @@ return false; } function _callback(result, req) { - handleFormValidationResponse(formid, onsuccess, result); + handleFormValidationResponse(formid, onsuccess, onfailure, result); } d.addCallback(_callback); return false;