diff --git a/js/conditional_fields.js b/js/conditional_fields.js index 61e0bbde4c2c5571189b7df3551114b48eb21ed1..319f7d1eb8f2dc7ac6d546541a1a025aa348eb4d 100644 --- a/js/conditional_fields.js +++ b/js/conditional_fields.js @@ -120,6 +120,11 @@ .on('state:required', (e) => { if (e.trigger) { const fieldsSupportingRequired = $(e.target).find('input, textarea'); + + // Option 'N/A' etc should not be present when field is required. + const requiredNoneOption = fieldsSupportingRequired + .filter('[id*="component-none"]') + .parent(); const legends = $(e.target).find('legend'); const legendsspan = $(e.target).find('legend span'); const labels = $(e.target).find( @@ -139,6 +144,9 @@ if (tabs.length !== 0) { tab.find('strong').addClass('form-required'); } + if (requiredNoneOption.length !== 0) { + requiredNoneOption.hide(); + } } else { labels.addClass('form-required'); } @@ -152,6 +160,9 @@ if (tabs.length !== 0) { tab.find('strong').removeClass('form-required'); } + if (requiredNoneOption.length !== 0) { + requiredNoneOption.show(); + } } else { labels.removeClass('form-required'); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3818cb44bb9de64a1c416c1505cbdad6b9f442a4..e4de95c2eb999b4a3912a43f882de9ef37a95540 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,17 +1,62 @@ parameters: ignoreErrors: + - + message: "#^Variable \\$parent might not be defined\\.$#" + count: 1 + path: src/ConditionalFieldsElementAlterHelper.php - - message: "#^Variable \\$selectors in empty\\(\\) is never defined\\.$#" + message: "#^Variable \\$error_key_arr on left side of \\?\\? always exists and is not nullable\\.$#" count: 1 - path: src/Plugin/conditional_fields/handler/TextAreaFormatted.php + path: src/ConditionalFieldsFormHelper.php - - message: "#^Undefined variable\\: \\$selectors$#" + message: "#^Variable \\$field_name might not be defined\\.$#" + count: 3 + path: src/ConditionalFieldsFormHelper.php + + - + message: "#^Variable \\$first_field might not be defined\\.$#" count: 1 - path: src/Plugin/conditional_fields/handler/TextAreaFormatted.php + path: src/ConditionalFieldsFormHelper.php + + - + message: "#^Variable \\$storage might not be defined\\.$#" + count: 1 + path: src/ConditionalFieldsFormHelper.php + + - + message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#" + count: 1 + path: src/ConditionalFieldsFormHelper.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/Form/ConditionalFieldDeleteForm.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/Form/ConditionalFieldEditForm.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/Form/ConditionalFieldForm.php - message: "#^Variable \\$regex in empty\\(\\) is never defined\\.$#" count: 1 path: src/Plugin/conditional_fields/handler/LanguageSelect.php + + - + message: "#^Undefined variable\\: \\$selectors$#" + count: 1 + path: src/Plugin/conditional_fields/handler/TextAreaFormatted.php + + - + message: "#^Variable \\$selectors in empty\\(\\) is never defined\\.$#" + count: 1 + path: src/Plugin/conditional_fields/handler/TextAreaFormatted.php +