php - how to override a web form submit function in drupal7? -
i have web form name , email fields. when form submitted name , email should store in database , pdf file should start download.
my question how override submit function of web form can add function after that?
you need create custom module hook_form_alter() implementation.
function [your_module]_form_alter(&$form, &$form_state, $form_id) { if($form_id == "your_form_id") { // target submit button , add new submission callback routine form $form['#submit'][] = 'your_submission_callback_function'; } }
the code above execute new callback function your_submission_callback_function
after form's default callback function.
to make new callback function called before form's default callback function, use following code instead of giving above:
array_unshift($form['#submit'], 'your_submission_callback_function');
to cancel form's default callback function , force use function only, use code below
$form['#submit'] = array('your_submission_callback_function');
hope help.
Comments
Post a Comment