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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -