How to add two extra buttons in a form to do extra actions with form data I have a simple custom form with 3 submit buttons - one that calls the default hook_form_submit and generates a table. The submit as the rebuild as TRUE:

$form_state['rebuild'] = TRUE;


that shows the complete form with the 3 buttons and the tables.

I need the 2 extra buttons to call different functions but I need inputs from the form itself or the table array.

At the moment, with the code I have, I can't access the form data and also, the tables created by the main submit disappear when I click the 2 extra buttons.

My code:

function MYMOUDLE_form($form, &amp;$form_state) {
    $form['container']['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t("Submit Form"),  
    );

    $form['container']['export_1'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t("Export - 1"),
        '#submit' =&gt; array('MYMOUDLE_export_1'),
    );

    $form['container']['export_2'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t("Export - 2"),
        '#submit' =&gt; array('MYMOUDLE_export_2'),
    );

    return $form;
}

function MYMOUDLE_form_submit($form, &amp;$form_state) {
    # do my stuff - generate tables
}

function MYMOUDLE_export_1($form, $form_values) {
    dpm($form_values);
    $someData1 = MYMODULE_handleFormData1($formValue1, $formValue2, $formValue3);
    drupal_set_message('Action for export 1 was done successfully.');
}

function MYMOUDLE_export_2($form, $form_values) {
    dpm($form_values);
    $someData2 = MYMODULE_handleFormData2($formValue1, $formValue2, $formValue3);
    drupal_set_message('Action for export 2 was done successfully.');
}
Rather than write submit function for each button use $form_state['triggering_element']. This will provide you the which button is clicked with form data in default hook_form_submit