Skip to content

Commit

Permalink
Fix issues with select2 validation when it is part of hidden 'On beha…
Browse files Browse the repository at this point in the history
…lf of organisation' block
  • Loading branch information
mattwire committed Jun 20, 2020
1 parent b88d460 commit 1960831
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@
selectCreateOrg(orgOption, false);

if (is_for_organization.length) {
$('#on-behalf-block').toggle(is_for_organization.is(':checked'));
showHideOnBehalfOfBlock();

is_for_organization.on('change', function() {
showHideOnBehalfOfBlock();
});
}

is_for_organization.on('change', function(){
$('#on-behalf-block').toggle($(this).is(':checked'));
});
function showHideOnBehalfOfBlock() {
$('#on-behalf-block').toggle(is_for_organization.is(':checked'));

if (is_for_organization.is(':checked')) {
$('#onBehalfOfOrg select.crm-select2').removeClass('crm-no-validate');
}
else {
$('#onBehalfOfOrg select.crm-select2').addClass('crm-no-validate');
}
}

$("input:radio[name='org_option']").click( function( ) {
var orgOption = $(this).attr('id');
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/common/l10n.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
var params = {
errorClass: 'crm-inline-error alert-danger',
messages: {},
ignore: ".select2-offscreen, [readonly], :hidden:not(.crm-select2)"
ignore: '.select2-offscreen, [readonly], :hidden:not(.crm-select2), .crm-no-validate'
};
// use civicrm notifications when there are errors
Expand Down

0 comments on commit 1960831

Please sign in to comment.