You are here

public function ProfileForm::editCancelSubmit in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/src/ProfileForm.php \Drupal\user\ProfileForm::editCancelSubmit()

Provides a submit handler for the 'Cancel account' button.

File

core/modules/user/src/ProfileForm.php, line 45

Class

ProfileForm
Form handler for the profile forms.

Namespace

Drupal\user

Code

public function editCancelSubmit($form, FormStateInterface $form_state) {
  $destination = [];
  $query = $this
    ->getRequest()->query;
  if ($query
    ->has('destination')) {
    $destination = [
      'destination' => $query
        ->get('destination'),
    ];
    $query
      ->remove('destination');
  }

  // We redirect from user/%/edit to user/%/cancel to make the tabs disappear.
  $form_state
    ->setRedirect('entity.user.cancel_form', [
    'user' => $this->entity
      ->id(),
  ], [
    'query' => $destination,
  ]);
}