function redirect_save_edit_submit in Save & Edit 6
Same name and namespace in other branches
- 7 save_edit.module \redirect_save_edit_submit()
Custom Submit Handler for Redirecting Save & Edit's to the node form after saving
_state
Parameters
$form:
1 string reference to 'redirect_save_edit_submit'
- save_edit_form_alter in ./
save_edit.module - Implementation of hook_form_alter().
File
- ./
save_edit.module, line 184
Code
function redirect_save_edit_submit($form, &$form_state) {
// we will first check to see if they want to auto-unpublish, and make modifications if so
// before submitting the node
// ONLY do something on new nodes
if (variable_get('save_edit_unpublish_new_only', 0) && !$form_state['values']['nid']) {
$form_state['values']['status'] = 0;
}
elseif (variable_get('save_edit_unpublish', 0) && !variable_get('save_edit_unpublish_new_only', 0)) {
$form_state['values']['status'] = 0;
}
// WAIT... if someone clicked the Publish button, maybe we should retick that option now
if ($form_state['clicked_button']['#id'] == 'edit-save-edit-publish') {
$form_state['values']['status'] = 1;
}
// call default node save/submit function
node_form_submit($form, $form_state);
// only redirect if using the Save & Edit button
if ($form_state['clicked_button']['#id'] == 'edit-save-edit') {
// change redirect location
if ($_REQUEST['destination']) {
$form_state['redirect'] = url('node/' . $form_state['nid'] . '/edit', array(
'query' => array(
'destination' => $_REQUEST['destination'],
),
'absolute' => TRUE,
));
unset($_REQUEST['destination']);
}
else {
// just go back to the form edit page, and dont worry about the redirect
$form_state['redirect'] = 'node/' . $form_state['nid'] . '/edit';
}
}
}