function FieldStorageConfigEditForm::save

Same name and namespace in other branches
  1. 8.9.x core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::save()
  2. 10 core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::save()
  3. 11.x core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::save()

Overrides EntityForm::save

File

core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php, line 226

Class

FieldStorageConfigEditForm
Provides a form for the "field storage" edit page.

Namespace

Drupal\field_ui\Form

Code

public function save(array $form, FormStateInterface $form_state) {
    $field_label = $form_state->get('field_config')
        ->label();
    try {
        $this->entity
            ->save();
        $this->messenger()
            ->addStatus($this->t('Updated field %label field settings.', [
            '%label' => $field_label,
        ]));
        $request = $this->getRequest();
        if (($destinations = $request->query
            ->get('destinations')) && ($next_destination = FieldUI::getNextDestination($destinations))) {
            $request->query
                ->remove('destinations');
            $form_state->setRedirectUrl($next_destination);
        }
        else {
            $form_state->setRedirectUrl(FieldUI::getOverviewRouteInfo($form_state->get('entity_type_id'), $form_state->get('bundle')));
        }
    } catch (\Exception $e) {
        $this->messenger()
            ->addStatus($this->t('Attempt to update field %label failed: %message.', [
            '%label' => $field_label,
            '%message' => $e->getMessage(),
        ]));
    }
}

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