Skip to content

Instantly share code, notes, and snippets.

@guoxiangke
Created January 18, 2013 03:42
Show Gist options
  • Save guoxiangke/4562166 to your computer and use it in GitHub Desktop.
Save guoxiangke/4562166 to your computer and use it in GitHub Desktop.
关键点: '#type' => 'submit', '#limit_validation_errors' => array(), '#submit' => array('yourmodule_cancel_buttons_callback')
/**
* @file
* Defines a Cancel button on node forms
*/
function yourmodule_cancel_form_node_form_alter(&$form, &$form_state) {
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#weight' => 20,
'#executes_submit_callback' => TRUE,
'#limit_validation_errors' => array(),
'#submit' => array('yourmodule_cancel_buttons_callback')
);
}
/**
* Custom cancel button callback.
*/
function yourmodule_cancel_buttons_callback($form, &$form_state) {
$node = $form['#node'];
druedu_redirect_callback($node, $flag = TRUE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment