[development] resetting a form

Si Hobbs simon at hobbs.id.au
Wed Mar 7 00:57:35 UTC 2012


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_clear_all('form_state_' .
$form_state['values']['form_build_id'], 'cache_form');

Thanks for any tips.


More information about the development mailing list