function ShortcutSetForm::save

Same name in other branches
  1. 9 core/modules/shortcut/src/ShortcutSetForm.php \Drupal\shortcut\ShortcutSetForm::save()
  2. 8.9.x core/modules/shortcut/src/ShortcutSetForm.php \Drupal\shortcut\ShortcutSetForm::save()
  3. 10 core/modules/shortcut/src/ShortcutSetForm.php \Drupal\shortcut\ShortcutSetForm::save()

Overrides EntityForm::save

File

core/modules/shortcut/src/ShortcutSetForm.php, line 50

Class

ShortcutSetForm
Form handler for the shortcut set entity edit forms.

Namespace

Drupal\shortcut

Code

public function save(array $form, FormStateInterface $form_state) {
    $entity = $this->entity;
    $is_new = !$entity->getOriginalId();
    $entity->save();
    if ($is_new) {
        $this->messenger()
            ->addStatus($this->t('The %set_name shortcut set has been created. You can edit it from this page.', [
            '%set_name' => $entity->label(),
        ]));
    }
    else {
        $this->messenger()
            ->addStatus($this->t('Updated set name to %set-name.', [
            '%set-name' => $entity->label(),
        ]));
    }
    $form_state->setRedirectUrl($this->entity
        ->toUrl('customize-form'));
}

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