You are here

protected function ConditionalFieldForm::requiredFieldIsNotVisible in Conditional Fields 8

Same name and namespace in other branches
  1. 4.x src/Form/ConditionalFieldForm.php \Drupal\conditional_fields\Form\ConditionalFieldForm::requiredFieldIsNotVisible()

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.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field: The field to evaluate.

null|string $state: The configured state for the field.

Return value

bool TRUE if the field is required but not visible; FALSE otherwise.

1 call to ConditionalFieldForm::requiredFieldIsNotVisible()
ConditionalFieldForm::validateForm in src/Form/ConditionalFieldForm.php
Form validation handler.

File

src/Form/ConditionalFieldForm.php, line 194

Class

ConditionalFieldForm
Class ConditionalFieldForm.

Namespace

Drupal\conditional_fields\Form

Code

protected function requiredFieldIsNotVisible(FieldDefinitionInterface $field, $state) : bool {
  return method_exists($field, 'isRequired') && $field
    ->isRequired() && in_array($state, [
    '!visible',
    'disabled',
    '!required',
  ]);
}