public ViewEditForm::submitDelayDestination($form, FormStateInterface $form_state)
Submit handler for form buttons that do not complete a form workflow.
The Edit View form is a multistep form workflow, but with state managed by the SharedTempStore rather than $form_state->setRebuild(). Without this submit handler, buttons that add or remove displays would redirect to the destination parameter (e.g., when the Edit View form is linked to from a contextual link). This handler can be added to buttons whose form submission should not yet redirect to the destination.
File
- core/modules/views_ui/src/ViewEditForm.php, line 771
Class
- ViewEditForm
- Form controller for the Views edit form.
Namespace
Drupal\views_ui
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | public function submitDelayDestination( $form , FormStateInterface $form_state ) { $request = $this ->requestStack->getCurrentRequest(); $destination = $request ->query->get( 'destination' ); $redirect = $form_state ->getRedirect(); // If there is a destination, and redirects are not explicitly disabled, add // the destination as a query string to the redirect and suppress it for the // current request. if (isset( $destination ) && $redirect !== FALSE) { // Create a valid redirect if one does not exist already. if (!( $redirect instanceof Url)) { $redirect = Url::createFromRequest( $request ); } // Add the current destination to the redirect unless one exists already. $options = $redirect ->getOptions(); if (!isset( $options [ 'query' ][ 'destination' ])) { $options [ 'query' ][ 'destination' ] = $destination ; $redirect ->setOptions( $options ); } $form_state ->setRedirectUrl( $redirect ); $request ->query->remove( 'destination' ); } } |
Please login to continue.