You are here

function rh_bean_form_submit in Rabbit Hole 7.2

Custom submit function for the bean edit form.

This will fire after the regular submit function, and its purpose is to make sure that the user does not get redirected to block/% after saving the bean, if any Rabbit Hole action is enabled. This works by redirecting the user to block/%/edit, if a destination parameter has not been set.

See also

node_form_submit()

1 string reference to 'rh_bean_form_submit'
rh_bean_form_bean_form_alter in modules/rh_bean/rh_bean.module
Implements hook_form_FORM_ID_alter().

File

modules/rh_bean/rh_bean.module, line 84
Main module file for Rabbit Hole beans module.

Code

function rh_bean_form_submit($form, &$form_state) {

  // Get the action. Either the one specified for this bean, or the default
  // value for the bean 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('bean', $form['#entity']->type);

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