Skip to content

Commit

Permalink
Fix implementation of jQuery.validate so that it actually uses the CR…
Browse files Browse the repository at this point in the history
…M settings, validates select2 fields and uses Civi/bootstrap classes for errors
  • Loading branch information
mattwire committed Feb 10, 2020
1 parent e9ada0a commit 374f3dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions js/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,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) {
Expand Down Expand Up @@ -1615,7 +1615,7 @@ if (!CRM.vars) CRM.vars = {};
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
return entityMap[s];
});
}
};

// CVE-2015-9251 - Prevent auto-execution of scripts when no explicit dataType was provided
$.ajaxPrefilter(function(s) {
Expand Down
5 changes: 2 additions & 3 deletions templates/CRM/common/l10n.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 374f3dd

Please sign in to comment.