One submit button posting to multiple functions I am displaying a form inside a block and I want it to submit to multiple functions, namely the original submit functions and in addition my own pm_form_submit. Yet I can't get it to work... you can submit to multiple functions right?

In the case bellow only "Test Form Submit" (the original submit function) is displayed.

Submit button of my test form:

function test_form_form ($form,&amp;$form_state){
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Submit',
  );

  return $form;
}


My code for displaying the form in a block:

$form = drupal_get_form ('test_form_form');

//add our submit function (both are here just to test)
$form ['#submit'][] = 'pm_form_submit';
$form ['submit']['#submit'][] = 'pm_form_submit';

$output .= drupal_render ($form);
return $output;


My submit functions: (the pm_form submit is in the same file where I alter the form and the test_form_form_submit is in the file where the form is generated)

function pm_form_submit ($form, &amp;$form_state) {
  drupal_set_message('pm_form_submit');
}

function test_form_form_submit(&amp;$form, &amp;$form_state) {
  drupal_set_message('Test Form Submit');
}


when I print_r the $form array I can see the following:

[submit] =&gt; Array
    (
        [#type] =&gt; submit
        [#value] =&gt; Submit
        [#input] =&gt; 1
        [#name] =&gt; op
        [#button_type] =&gt; submit
        [#executes_submit_callback] =&gt; 1
        [#limit_validation_errors] =&gt; 
        [#process] =&gt; Array
            (
                [0] =&gt; ajax_process_form
            )

        [#theme_wrappers] =&gt; Array
            (
                [0] =&gt; button
            )

        [#defaults_loaded] =&gt; 1
        [#tree] =&gt; 
        [#parents] =&gt; Array
            (
                [0] =&gt; submit
            )

        [#weight] =&gt; 0.001
        [#processed] =&gt; 1
        [#required] =&gt; 
        [#attributes] =&gt; Array
            (
            )

        [#title_display] =&gt; before
        [#id] =&gt; edit-submit
        [#ajax_processed] =&gt; 
        [#sorted] =&gt; 1
        [#submit] =&gt; Array
            (
                [0] =&gt; pm_form_submit
            )

    )


...
[#submit] =&gt; Array
    (
        [0] =&gt; test_form_form_submit
        [1] =&gt; pm_form_submit
    )
You can't add submit handlers to form after drupal_get_form() is called, because they will not be processed.

You need to add submit handler in hook_form_alter(). If you want add this handler only in specific cases, you can add cutom parameter to drupal_get_form()

Code in block:

$form = drupal_get_form('test_form_form', 'add_pm');
$output .= drupal_render($form);
return $output;


Code in custom module:

function MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
   if (($form_id == 'test_form_form') &amp;&amp; ($form_state['build_info']['args'][0] == 'add_pm')) {
     // add custom submit only if form was called with parameter. 
     $form ['#submit'][] = 'pm_form_submit';
   }
}

function pm_form_submit($form, &amp;$form_state) {
  drupal_set_message('pm_form_submit');
}