You are here

protected function FieldStorageAddForm::validateAddExisting in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field_ui/src/Form/FieldStorageAddForm.php \Drupal\field_ui\Form\FieldStorageAddForm::validateAddExisting()
  2. 9 core/modules/field_ui/src/Form/FieldStorageAddForm.php \Drupal\field_ui\Form\FieldStorageAddForm::validateAddExisting()

Validates the 're-use existing field' case.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

See also

\Drupal\field_ui\Form\FieldStorageAddForm::validateForm()

1 call to FieldStorageAddForm::validateAddExisting()
FieldStorageAddForm::validateForm in core/modules/field_ui/src/Form/FieldStorageAddForm.php
Form validation handler.

File

core/modules/field_ui/src/Form/FieldStorageAddForm.php, line 302

Class

FieldStorageAddForm
Provides a form for the "field storage" add page.

Namespace

Drupal\field_ui\Form

Code

protected function validateAddExisting(array $form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('existing_storage_name')) {

    // Missing label.
    if (!$form_state
      ->getValue('existing_storage_label')) {
      $form_state
        ->setErrorByName('existing_storage_label', $this
        ->t('Re-use existing field: you need to provide a label.'));
    }
  }
}