I added the following code in hook_form_alter() and I get my button on the Add/Edit node form:
$form['actions']['save_add_lesson'] = array(
'#type' => 'submit',
'#value' => 'Save & Add a Lesson',
'#name' => 'op',
'#submit' => array('mymodule_node_form_submit'), /* NEED this */
'#weight' => 1000
);
But, clicking the button doesn't seem to hit hook_node_submit() or hook_node_insert(). I'm assuming I'm missing a hook or something in the button creation...anyone have any ideas?
Then added this function:
function mymodule_node_form_submit($form, &$form_state) {
// Do stuff before saving the node
// Call this to save the node
node_form_submit($form, $form_state);
// Do stuff after saving the node
}
submit
instead of abutton
, that normally does the trick for me