Last active
November 9, 2020 18:34
-
-
Save juampynr/660219418bde29b6d107 to your computer and use it in GitHub Desktop.
Make Drupal 7 not to redirect to the node display after saving it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Implements hook_form_BASE_FORM_ID_alter(). | |
| */ | |
| function mymodule_form_node_form_alter(&$form, &$form_state, $form_id) { | |
| $form['actions']['submit']['#submit'][] = '_mymodule_node_submit_redirect'; | |
| } | |
| /** | |
| * Extra node form submit handler. Done this way to override the default. | |
| */ | |
| function _mymodule_node_submit_redirect($form, &$form_state) { | |
| if (isset($_GET['destination'])) { | |
| unset($_GET['destination']); | |
| } | |
| $form_state['redirect'] = 'node/' . $form_state['nid'] . '/edit/'; | |
| } |
Author
Thanks @zanvidmar! I updated the gist so it states the version and also referenced your comment for Drupal 8.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the code snippet. I am not sure for which core version this applies. However since $form_state is an object, this code snippet should be updated to: