[javascript] fid form / onfailure behaviour stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Thu, 12 Nov 2009 18:27:59 +0100
branchstable
changeset 3834 e3e64352063d
parent 3833 5507aa75f601
child 3837 0cb409871d42
[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.
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;
 }