Drupal - Force redirect in submit handler even though destination parameter set

The only correct way to do this is to alter the Request object and drop the destination.

In your submit callback:

\Drupal::request()->query->remove('destination');

Depending on the context, you might want to store it somewhere, for example pass it along to the URL you are redirecting to, so that it is respected again later.

See https://www.drupal.org/node/2325463 for a core issue that is doing exactly this to fix the preview button if a destination is given.

Tags:

8

Redirection