How to specify multiple submit handlers for multiple forms I am implementing hook_forms in my custom module and I don't know how to have multiple form submit handlers.

Here is my custom form function:

function data_retrieval_main_form()
{
    $form ['field2'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Name'),
        '#default_value' =&gt; $name,
        '#maxlength' =&gt; 127,
    );

    $form ['field3'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Age'),
        '#default_value' =&gt; $age,
        '#maxlength' =&gt; 127,
    );

    $form['fileupload'] = array(
        '#title' =&gt; t('Choose Image'),
        '#type' =&gt; 'file',
    );

    $form ['submit_field'] = array(
        '#type' =&gt; 'submit',
        '#default_value' =&gt; 'Submit',
    );

    return $form;
}


Here I am implementing hook_forms:

 function hook_forms($form_id, $args) {

      $forms ['mymodule_first_form'] = array(
        'callback' =&gt; 'data_retrieval_main_form',
      );


      $forms ['mymodule_second_form'] = array(
        'callback' =&gt; 'mymodule_main_form',
        'callback arguments' =&gt; array('some parameter'),
      );

      return $forms;
    }


Now I previously had a single form using hook_form and the handler was simply like this:

function data_retrieval_form_submit($form_id, &amp;$form_state)
{
// validation and submission of form 
}


But now that I have multiple forms, how do I have multiple submit handlers for the forms, is there a way in Drupal that checks which form is being submitted?
You can specify a submit handler for each of your forms. Examples:

Override default handler with custom handler (new array):

$form['#submit'] = array('data_retrieval_form_submit');


Run custom handler after default (append to array):

$form['#submit'][] = 'data_retrieval_form_submit';


Run custom handler before default (prepend array):

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


You can add it to the $form array in a custom form builder function, or alter an existing form via hook_form_alter.