Drupal 7 custom form submit handler is not being called I am trying to write a custom handler for one of the Drupal 7 forms:

function mymodule_formid_alter(&amp;$form, &amp;$form_state, $form_id) {

 array_unshift($form['#submit'], 'mymodule_formid_submit');

}

function mymodule_formid_submit($form, &amp;$form_state) {
    drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
    return
}


But it is not accessing the handler. Alter method is being called and printing 'mymodule_formid_submit' in the #submit array.

Maybe I am missing something, but exiting answers on Stack Overflow related to custom handlers are not helping in my case.
I had this same problem trying to edit commerce_product form. For some reason the submit handlers are registered under actual submit button and custom handlers added to the #submit -element weren't registered.

$form['#submit'][] = 'my_custom_handler';
$form['actions']['submit']['#submit'][] = 'my_custom_handler';


So when I added that second line to register my custom handler to button and atleast it works.