CRM-16872 - Ensure errors are displayed from semi-ajax forms
authorColeman Watts <coleman@civicrm.org>
Thu, 23 Jul 2015 16:15:06 +0000 (12:15 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 23 Jul 2015 16:15:06 +0000 (12:15 -0400)
js/crm.ajax.js

index dfcebaeba45b49615eee3fdc3aa0cd61795a8401..7c180cd72414371aa3bf301d2ffa54a262e05eb2 100644 (file)
         that._handleOrderLinks();
         that.element.trigger('crmLoad', data);
         if (that.options.crmForm) that.element.trigger('crmFormLoad', data);
+        // This is only needed by forms that load via ajax but submit without ajax, e.g. configure contribution page tabs
+        // TODO: remove this when those forms have been converted to use ajax submit
+        if (data.status === 'form_error' && $.isPlainObject(data.errors)) {
+          that.element.trigger('crmFormError', data);
+          $.each(data.errors, function(formElement, msg) {
+            $('[name="'+formElement+'"]', that.element).crmError(msg);
+          });
+        }
       }).fail(function(data, msg, status) {
         that._onFailure(data, status);
       });