Drupal's default behavior is to redirect the user to the full display of a node after it has been saved.
If you want to stay in the edit form after saving, add this snippet to a custom module adjusting the module namespace in the two functions.
Drupal's default behavior is to redirect the user to the full display of a node after it has been saved.
If you want to stay in the edit form after saving, add this snippet to a custom module adjusting the module namespace in the two functions.
| /** | |
| * 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/'; | |
| } |
Thanks @zanvidmar! I updated the gist so it states the version and also referenced your comment for Drupal 8.
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: