You are here

function save_edit_form_submit_redirect in Save & Edit 8

We want to override the default redirect that was set in the saving process.

1 string reference to 'save_edit_form_submit_redirect'
save_edit_form_alter in ./save_edit.module
Implements hook_form_alter().

File

./save_edit.module, line 90
Contains save_edit.module..

Code

function save_edit_form_submit_redirect(&$form, FormStateInterface $form_state) {
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  $toUrl = $entity
    ->toUrl('edit-form');
  if ($destination = \Drupal::request()->query
    ->get('destination')) {
    $toUrl
      ->setRouteParameter("destination", $destination);
  }
  \Drupal::request()->query
    ->remove('destination');
  $form_state
    ->setRedirectUrl($toUrl);
}