From e3b2c4daca081ac709696b4edf0095ac9f26bf32 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 20 Jun 2020 21:54:31 +1000 Subject: [PATCH] [REF] Ensure that our custom error handler is called when jquery validates and expand any collapsed accordions that are hiding required fields that haven't been filled in --- js/Common.js | 2 ++ templates/CRM/common/l10n.js.tpl | 1 + 2 files changed, 3 insertions(+) diff --git a/js/Common.js b/js/Common.js index b1eba2836e..0199e80eb1 100644 --- a/js/Common.js +++ b/js/Common.js @@ -882,6 +882,8 @@ if (!CRM.vars) CRM.vars = {}; var validator = $(this).validate(); var that = this; validator.settings = $.extend({}, validator.settings, CRM.validate._defaults, CRM.validate.params); + // Call our custom validation handler. + $(validator.currentForm).on("invalid-form.validate", validator.settings.invalidHandler ); // Call any post-initialization callbacks if (CRM.validate.functions && CRM.validate.functions.length) { $.each(CRM.validate.functions, function(i, func) { diff --git a/templates/CRM/common/l10n.js.tpl b/templates/CRM/common/l10n.js.tpl index 023edfa3a6..60b4f223ad 100644 --- a/templates/CRM/common/l10n.js.tpl +++ b/templates/CRM/common/l10n.js.tpl @@ -104,6 +104,7 @@ // but there will be no overall message. Currently the container is only available on backoffice pages. if ($('#crm-notification-container').length) { $.each(validator.errorList, function(k, error) { + $(error.element).parents('.crm-custom-accordion.collapsed').crmAccordionToggle(); $(error.element).crmError(error.message); }); } -- 2.25.1