Re: resetting a form
Si Hobbs <[email protected]>
| Newsgroups | gmane.comp.php.drupal.devel |
|---|---|
| Message-ID | <CAKUW=8yePQDx65Ft2EFUyw5u=4N9UP9D6suK+cKNR3qdjEUcBA@mail.gmail.com> |
Oh yes, I'm talking about Drupal 7. I used to do all this with ctools in Drupal 6. Yes it works if I clean up the $form_state['values']. It feels a little weird but thanks heaps for that. Simon On 7 March 2012 12:12, David Metzler <[email protected]> wrote: > 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 >