web/data/cubicweb.edition.js
branchstable
changeset 1864 4ceaf8f2709b
parent 1798 cc86fe8efaaa
child 1868 af1ae863606d
--- 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;