When in admin overlay, submitting form over 400 times I have built a very simple module which just implements a block with a custom form. When submitted, the content is emailed to me. I show this block on the dashboard, and without the admin overlay it works totally fine.

But when I access the dashboard in the overlay and submit the form, I get no feedback at all (I user drupal_set_message() when the email is sent, but that doesn't show up) and half a minute later I find 437 copies of the same email in my inbox.

Unfortunately I have no idea at all where I could start debugging THIS. Maybe the overlay is just a coincidence. But what else could cause this massive submission of email and/or the form?

Any ideas are appreciated.

Thanks,

Victor

UPDATE: The (simplified) code below, this very basic form still has the same problem. How is this possible?

&lt;?php

function mvp_form_test_block_info() {
  $blocks = array(
    'mvp_form_test_test_block' =&gt; array(
      'info' =&gt; 'Test Form',
      'cache' =&gt; DRUPAL_CACHE_GLOBAL,
      'properties' =&gt; array(
        'administrative' =&gt; true,
      ),
    ),
  );
  return $blocks;
}

function mvp_form_test_block_view($delta='') {
  if ($delta != 'mvp_form_test_test_block')
    return array();

  return array(
    'title' =&gt; 'Test Block',
    'content' =&gt; drupal_get_form('mvp_form_test_test_form'),
  );
}

function mvp_form_test_test_form($form, &amp;$form_state) {
  $form = array();
  $form['sometext'] = array(
    '#type' =&gt; 'textfield',
  );
  $form['button'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Submit',
  );
  return $form;
}

function mvp_form_test_test_form_submit($form, $form_state) {
  watchdog('mvp_form_test', 'Form submitted with text '.$form_state['values']['sometext']);
  drupal_set_message('Form submitted with text '.$form_state['values']['sometext']);
}

?&gt;
Not sure what is exactly causing this, but maybe you can use a static variable as a workaround for this issue.

function mvp_form_test_test_form_submit($form, $form_state) {
  $sent =&amp; drupal_static(__FUNCTION__);
  if(!$sent) {
    watchdog('mvp_form_test', 'Form submitted with text '.$form_state['values']['sometext']);
    drupal_set_message('Form submitted with text '.$form_state['values']['sometext']);
    $sent = true;
  }
}