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 20, 2020
1 parent 667e9a9 commit f911204
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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 f911204

Please sign in to comment.