You are here

function rabbit_hole_node_form_submit in Rabbit Hole 6

Same name and namespace in other branches
  1. 7 rabbit_hole.module \rabbit_hole_node_form_submit()

Custom submit function for the node form.

This will fire after the regular submit function, and it's purpose is to make sure that the user doesn't get redirected to node/123 after saving the node, if any Rabbit Hole action is enabled. This works by redirecting the user to node/123/edit, if a destination parameter hasn't been set.

See also

node_form_submit().

1 string reference to 'rabbit_hole_node_form_submit'
rabbit_hole_form_alter in ./rabbit_hole.module
Implements hook_form_FORM_ID_alter().

File

./rabbit_hole.module, line 195
Main module file for Rabbit Hole.

Code

function rabbit_hole_node_form_submit($form, &$form_state) {

  // Get the action. Either the one specified for this node, or the default
  // value for the content type.
  $action = $form_state['values']['rabbit_hole_action'] != RABBIT_HOLE_USE_DEFAULT ? $form_state['values']['rabbit_hole_action'] : variable_get('rabbit_hole_action_' . $form_state['values']['type'], RABBIT_HOLE_DISPLAY_CONTENT);

  // If the action says anything else than to display the content, make sure
  // that the user doesn't land on the node view page. We'll check if a custom
  // redirect path has been set, otherwise, we'll redirect the user to the edit
  // page again.
  if ($action != RABBIT_HOLE_DISPLAY_CONTENT && $form_state['redirect'] == 'node/' . $form_state['values']['nid']) {
    $form_state['redirect'] = 'node/' . $form_state['values']['nid'] . '/edit';
  }
}