diff --git a/CHANGELOG.md b/CHANGELOG.md index bd06b02..1237d71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.10.6 (2022-01-25) + +- Allow conditional section to match any value from a comma-seperated list. + ## 1.10.5 (2021-09-07) - Fixes a bug where only the first input of type "file" was being submitted on form submit. diff --git a/lib/modules/apostrophe-forms-conditional-widgets/index.js b/lib/modules/apostrophe-forms-conditional-widgets/index.js index 722e06a..edf2636 100644 --- a/lib/modules/apostrophe-forms-conditional-widgets/index.js +++ b/lib/modules/apostrophe-forms-conditional-widgets/index.js @@ -13,7 +13,7 @@ module.exports = { { name: 'conditionValue', label: 'Value to check for to show this group.', - htmlHelp: 'If using a boolean/opt-in field, set this to "true".', + htmlHelp: 'If using a boolean/opt-in field, set this to "true". Use comma-separated values to check multiple values on this field (an OR relationship).', required: true, type: 'string' }, diff --git a/lib/modules/apostrophe-forms-conditional-widgets/public/js/lean.js b/lib/modules/apostrophe-forms-conditional-widgets/public/js/lean.js index ffb7214..f8f6881 100644 --- a/lib/modules/apostrophe-forms-conditional-widgets/public/js/lean.js +++ b/lib/modules/apostrophe-forms-conditional-widgets/public/js/lean.js @@ -21,7 +21,14 @@ apos.aposForms.checkConditional = function (groups, input) { activate = false; } - if (input.value === conditionValue && activate) { + var conditionCommaArray = conditionValue.split(','); + + var inputMatchesCondition = false; + if (conditionCommaArray.indexOf(input.value) > -1) { + inputMatchesCondition = true; + } + + if (inputMatchesCondition || (input.value === conditionValue && activate)) { fieldSet.removeAttribute('disabled'); } else { fieldSet.setAttribute('disabled', true);