You are here

protected function ConditionalFieldForm::requiredFieldIsNotVisible in Conditional Fields 4.x

Same name and namespace in other branches
  1. 8 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 211

Class

ConditionalFieldForm
A form with a list of conditional fields for an entity type.

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',
  ]);
}