How to get $form_state['values'] after a drupal_get_form() call? I have an form in a block with ajax submission. The block view code calls drupal_get_form, adds some other info, uses a custom theme tpl to create the block.

I want to replace the form in the block with a thank you message after successful submission.

AJAX works: The ajax on the submit element of the form means that a custom ajax callback  can replace the entire form with another themed chunk, passing in the form values received by the form so they can be merged in the thank you template. This works well because the ajax function has access to the form_state.

But what if AJAX is unavailable on the client? Then the normal form submit happens and the block view function just gets a blank form.

So how can my block view function get hold of the submitted values to feed them into the thank you template? 

Edit: messy work-arounds


I could just access $_POST but that's nasty and unvalidated! yuk
In the submit handler I can copy the $form_state['values'] variable to a superglobal, and check for that.
I realise this is an old question but: drupal_get_form() is mostly a wrapper for drupal_build_form(), and (the docs say) is intended to be used "instead of drupal_build_form() when $form_state is not needed", with the implication that if $form_state is needed, it's OK to go straight to drupal_build_form().

The only extra bit drupal_get_form does is assemble a 'build_info' array in the $form_state, so instead of (e.g.) $block['content']['form'] = drupal_get_form('myform_name', $arg);, you could do something like this:

  $form_state = array();
  $form_state['build_info']['args'][] = $arg;
  $block['content']['form'] = drupal_build_form('myform_name', $form_state);


You should find your $form_state variable is now populated as it would be if you were operating inside the form building function, including any $form_state['values'] or $form_state['input'] in the event that your form is being rebuilt.