function FieldStorageAddForm::validateForm

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

Overrides FormBase::validateForm

File

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

Class

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

Namespace

Drupal\field_ui\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  // Missing field type.
  if (!$form_state->getValue('new_storage_type') && !$form_state->getValue('existing_storage_name')) {
    $form_state->setErrorByName('new_storage_type', $this->t('You need to select a field type or an existing field.'));
  }
  elseif ($form_state->getValue('new_storage_type') && $form_state->getValue('existing_storage_name')) {
    $form_state->setErrorByName('new_storage_type', $this->t('Adding a new field and re-using an existing field at the same time is not allowed.'));
    return;
  }
  $this->validateAddNew($form, $form_state);
  $this->validateAddExisting($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.