From f91120401aa48d712eabb7433a0c1da787536f60 Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Fri, 7 Feb 2020 15:35:46 +0000 Subject: [PATCH] Fix implementation of jQuery.validate so that it actually uses the CRM settings, validates select2 fields and uses Civi/bootstrap classes for errors --- js/Common.js | 6 +++--- templates/CRM/common/l10n.js.tpl | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/js/Common.js b/js/Common.js index f4c2a60a6f09..d603d2748876 100644 --- a/js/Common.js +++ b/js/Common.js @@ -850,9 +850,9 @@ if (!CRM.vars) CRM.vars = {}; */ $.fn.crmValidate = function(params) { return $(this).each(function () { - var that = this, - settings = $.extend({}, CRM.validate._defaults, CRM.validate.params); - $(this).validate(settings); + var validator = $(this).validate(); + var that = this; + validator.settings = $.extend({}, validator.settings, CRM.validate._defaults, CRM.validate.params); // 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 74777751aec8..c76d15de0980 100644 --- a/templates/CRM/common/l10n.js.tpl +++ b/templates/CRM/common/l10n.js.tpl @@ -91,10 +91,9 @@ {literal} var params = { - errorClass: 'crm-inline-error', + errorClass: 'error alert-danger', messages: {}, - // TODO: remove after resolution of https://github.com/jzaefferer/jquery-validation/pull/1261 - ignore: ":hidden, [readonly]" + ignore: ".select2-offscreen, [readonly], :hidden:not(.crm-select2)" }; // use civicrm notifications when there are errors