[development] resetting a form

David Metzler metzler.dl at gmail.com
Wed Mar 7 01:12:59 UTC 2012

Tools are substantially different for the based on drupal 6 vs. 7.   Could you specify the version? 

Is there a reason not to simply alter $form_state['values'] as part of your submit handler?   I would've done it the other way around.  Imbed the thank you message in the form as a markup item, rather than trying to put it outside of the form.

On Mar 6, 2012, at 4:57 PM, Si Hobbs wrote:

> Hi
> I am doing an ajax callback, and I want to return a fresh version of a
> form as content. This is after the form has successfully submitted.
> So instead of something like:
>  return 'Thanks for your submission';
> Which works, I want to do:
>  return 'Thanks for your submission' . drupal_render(drupal_get_form('foo'));
> However when I get that that form, it is not fresh. The form system
> reprocesses the form, re-runs the submit handler, and returns a form
> with the $form_state['values'] all populated.
> So, I've been trying to work out how to reset the form. For example,
> this sort of thing doesn't successfully clear the form:
>    cache_clear_all('form_' . $form_state['values']['form_build_id'],
> 'cache_form');
>    cache_clear_all('form_state_' .
> $form_state['values']['form_build_id'], 'cache_form');
>    drupal_static_reset('drupal_retrieve_form');
> Thanks for any tips.
> Simon

More information about the development mailing list