How to use confirm_form OK this one is driving me nuts. I've read the other question posted on DrupalAnswers and several threads on the Internet, but I still can't work this out.

In my menu hook I have this:

$items['import'] = array(
    'title' =&gt; '',
    'type' =&gt; MENU_CALLBACK,
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('_my_module_form'),
    'access arguments' =&gt; array('access content'),
);


Then I have these functions:

function _my_module_form($form_state) {
 if(!isset($form_state['storage']['confirm'])) {

  $form ['some_textarea'] = array(
   '#type' =&gt; 'textarea',
   '#rows' =&gt; 25,
   '#cols' =&gt; 10,
  );

  $form['submit'] = array(
   '#type' =&gt; 'submit',
   '#value' =&gt; 'Import',
  );

  return $form;
 } else {
  drupal_set_message('hello');
  return confirm_form($form);
 }
}

function _my_module_form_validate($form, &amp;$form_state) {
 if(!isset($form_state['storage']['confirm'])) {  
 }
}

function _my_module_form_submit($form, &amp;$form_state) {
 if(!isset($form_state['storage']['confirm'])) {
  $form_state['storage']['confirm'] = TRUE;
  $form_state['rebuild'] = TRUE;
 } else {
  drupal_set_message('hello2');
 }
}


When I submit the form, nothing happens. I would expect to see the drupal message 'hello', but instead I just get the original form again. However, if I submit the form a second time, then I see a drupal message saying 'hello2'.

Why does the comfirm_form bit not get executed? It seems to me like the form state is not being rebuilt so the 'else' part of the conditional never gets executed.

Note: I am pretty sure form_validate is not needed, but I just put an empty definition in there in case.
Looks like my issue was here:

function _my_module_form($form_state) {


Should have been:

function _my_module_form($form, &amp;$form_state) {