Skip to content

Instantly share code, notes, and snippets.

@MKorostoff
Created March 16, 2015 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MKorostoff/b59fd31c9cd245b70df6 to your computer and use it in GitHub Desktop.
Save MKorostoff/b59fd31c9cd245b70df6 to your computer and use it in GitHub Desktop.
<?php
my_module_FORM_ID_alter(&$form) {
//Add a custom button
$form['my_button'] = array(
'#type' => 'button',
'#value' => t('My Buttom'),
'#executes_submit_callback' => TRUE,
);
//Add a custom submit handler
$form['#submit'][] = 'my_module_custom_submit_handler';
}
function my_module_custom_submit_handler($form, &$form_state) {
//Add a special redirect for users who clicked 'my_button'
if ($form_state['clicked_button']['#value'] === 'my_button') {
$form_state['redirect'] = 'path/to/my/special/redirect';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment