diff --git a/src/Form/ConditionalFieldForm.php b/src/Form/ConditionalFieldForm.php index 6c8a651..2232e3a 100644 --- a/src/Form/ConditionalFieldForm.php +++ b/src/Form/ConditionalFieldForm.php @@ -178,7 +178,20 @@ class ConditionalFieldForm extends FormBase { parent::validateForm($form, $form_state); } - protected function requiredFieldIsNotVisible(FieldDefinitionInterface $field, ?string $state): bool { + /** + * Determine if a field is configured to be required, but not visible. + * + * This is considered an error condition as a user would not be able to fill + * out the field. + * + * @param \Drupal\Core\Field\FieldDefinitionInterface $field + * The field to evaluate. + * @param null|string $state + * The configured state for the field. + * + * @return bool + * TRUE if the field is required but not visible; FALSE otherwise. + */ protected function requiredFieldIsNotVisible(FieldDefinitionInterface $field, $state): bool { return method_exists($field, 'isRequired') && $field->isRequired() && in_array($state, ['!visible', 'disabled', '!required']);