I've been trying to get to grips with the form api, I'm currently trying to hide a form after it has been submitted and to display a thank you template in the same area as the form was in.

Hoping someone might have an answer.


  • Why are you trying to stay on the same page without leaving and using the submit handler with a drupal_set_message()? Jan 16, 2014 at 19:05

1 Answer 1


Or use $form_state['rebuild'] in the submit handler and check for submitted values in the form builder. That way you can display the form the first time the user hit's the page, and after submission you display your message. This is something like a multistep form, so you could take any of the numerous tutorials for multistep forms in drupal. Also have look at the official example in form_example_tutorial.inc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.