# HG changeset patch # User Adrien Di Mascio # Date 1258046879 -3600 # Node ID e3e64352063de3547efa1040a8372e528a0e4bb0 # Parent 5507aa75f60185c945dc3c5342b9c2548c0a7bd6 [javascript] fid form / onfailure behaviour If onfailure is specified, it should be done _before_ any default / standard CW action is done. The callback signature should be the same as the onsuccess one. If the onfailure callback returns true, the default actions will still take place afterwards, otherwise (i.e. return false), the processing stops directly after the callback. diff -r 5507aa75f601 -r e3e64352063d web/data/cubicweb.edition.js --- a/web/data/cubicweb.edition.js Thu Nov 12 17:36:15 2009 +0100 +++ b/web/data/cubicweb.edition.js Thu Nov 12 18:27:59 2009 +0100 @@ -363,6 +363,9 @@ } return true; } + if (onfailure && !onfailure(result, formid, cbargs)) { + return false; + } unfreezeFormButtons(formid); // Failures _clearPreviousErrors(formid); @@ -376,9 +379,6 @@ _displayValidationerrors(formid, descr[0], descr[1]); updateMessage(_('please correct errors below')); document.location.hash = '#header'; - if (onfailure) { - onfailure(formid, cbargs); - } return false; }