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' => 'textfield',
'#title' => t('Name'),
'#default_value' => $name,
'#maxlength' => 127,
);
$form ['field3'] = array(
'#type' => 'textfield',
'#title' => t('Age'),
'#default_value' => $age,
'#maxlength' => 127,
);
$form['fileupload'] = array(
'#title' => t('Choose Image'),
'#type' => 'file',
);
$form ['submit_field'] = array(
'#type' => 'submit',
'#default_value' => 'Submit',
);
return $form;
}
Here I am implementing hook_forms
:
function hook_forms($form_id, $args) {
$forms ['mymodule_first_form'] = array(
'callback' => 'data_retrieval_main_form',
);
$forms ['mymodule_second_form'] = array(
'callback' => 'mymodule_main_form',
'callback arguments' => 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, &$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?