function mb_content_cancel_action in More Buttons 7
The "Cancel" action.
Handle different submit actions and make different redirects.
See also
1 call to mb_content_cancel_action()
- mb_content_cancel_validate in mb_content/
mb_content.module - Implements hook_form_validate().
File
- mb_content/
mb_content.module, line 419 - Provides additional buttons for nodes.
Code
function mb_content_cancel_action($form, &$form_state) {
// Hide the error messages.
drupal_get_messages('error');
$redirect = '<front>';
// $options query example:
// array('query' => array('destination' => 'node/' . $node->nid))
$options = array();
if (arg(0) === 'node' && arg(1) === 'add') {
// Limitation:
// Exist only one content type this redirect does not work.
$redirect = 'node/add';
if (isset($form['#tabcn_referer'])) {
$redirect = $form['#tabcn_referer'];
}
}
if (arg(0) === 'node' && is_numeric(arg(1)) && arg(2) === 'edit') {
$redirect = 'node/' . arg(1);
}
if (isset($form_state['storage']['#mb_redirect'])) {
$redirect = $form_state['storage']['#mb_redirect'];
}
elseif (isset($form['storage']['#mb_redirect'])) {
$redirect = $form['storage']['#mb_redirect'];
}
drupal_goto($redirect, $options);
}