[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.
--- 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;
}