Sometimes you are asked to add a second submit button above each node form.
This can be easily done with a few lines of code:
secondsubmit.info
; $Id$
name = "Second submit"
description = "Second submit button on node forms."
core = "6.x"
secondsubmit.module
// $Id$
/**
* @file
* Module definition for secondsubmit.
*/
/**
* Implement hook_form_alter().
*/
function secondsubmit_form_alter(&$form, $form_state, $form_id) {
// Add a second submit button to node forms.
if ($form['#node'] && ($form_id == $form['#node']->type . '_node_form')) {
$form['secondsubmit'] = array(
'#type' => 'submit',
'#value' => t('Save & continue'),
'#weight' => -10,
'#validate' => array('node_form_validate'),
// Use default and an additional submit handler.
'#submit' => array('node_form_submit', 'additional_node_form_submit'),
);
}
}
/**
* Implement of additional form submit
*/
function additional_node_form_submit($form, &$form_state) {
// ...
}
?>
No comments:
Post a Comment