function FieldConfigEditForm::handleEntityStorageException

Same name in other branches
  1. 11.x core/modules/field_ui/src/Form/FieldConfigEditForm.php \Drupal\field_ui\Form\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
Form submission handler for the 'save' action.
FieldConfigEditForm::submitForm in core/modules/field_ui/src/Form/FieldConfigEditForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form stateā€¦

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.