You are here

function rh_file_entity_edit_submit in Rabbit Hole 7.2

Custom submit function for the file entity edit 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 file/123 after saving the file, if any Rabbit Hole action is enabled. This works by redirecting the user to file/123/edit, if a destination parameter hasn't been set.

See also

node_form_submit()

1 string reference to 'rh_file_entity_edit_submit'
rh_file_form_file_entity_edit_alter in modules/rh_file/rh_file.module
Implements hook_form_FORM_ID_alter().

File

modules/rh_file/rh_file.module, line 97
Main module file for Rabbit Hole files module.

Code

function rh_file_entity_edit_submit($form, &$form_state) {

  // Get the action. Either the one specified for this file, or the default
  // value for the file type.
  $action = isset($form_state['values']['rh_action']) && $form_state['values']['rh_action'] != RABBIT_HOLE_USE_DEFAULT ? $form_state['values']['rh_action'] : rabbit_hole_get_action_bundle('file', $form['#entity']->type);

  // If the action says anything else than to display the content, make sure
  // that the user doesn't land on the file 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'] == 'file/' . $form_state['values']['fid']) {
    $form_state['redirect'] = 'file/' . $form_state['values']['fid'] . '/edit';
  }
}