function FieldConfigEditForm::handleEntityStorageException

Handles entity storage exceptions and redirects the form.

Parameters

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

\Drupal\Core\Entity\EntityStorageException $exception: The exception.

2 calls to FieldConfigEditForm::handleEntityStorageException()
FieldConfigEditForm::save in core/modules/field_ui/src/Form/FieldConfigEditForm.php
FieldConfigEditForm::submitForm in core/modules/field_ui/src/Form/FieldConfigEditForm.php

File

core/modules/field_ui/src/Form/FieldConfigEditForm.php, line 554

Class

FieldConfigEditForm
Provides a form for the field settings form.

Namespace

Drupal\field_ui\Form

Code

protected function handleEntityStorageException(FormStateInterface $form_state, EntityStorageException $exception) : void {
  $this->tempStore
    ->delete($this->entity
    ->getTargetEntityTypeId() . ':' . $this->entity
    ->getName());
  $form_state->setRedirectUrl(FieldUI::getOverviewRouteInfo($this->entity
    ->getTargetEntityTypeId(), $this->entity
    ->getTargetBundle()));
  $this->messenger()
    ->addError($this->t('An error occurred while saving the field: @error', [
    '@error' => $exception->getMessage(),
  ]));
}

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