By jan_v on
I'm still experimenting with writing small custom drupal modules.
I've maid a small module that gives the user a simple form after a certain action. All works fine, but after the form gets successfully submitted, the user gets to see the same form again.
I don't want that. When a user clicks the submit button, and form passes validation, i want a message to be shown to the user like "Thanks for submitting this form!" or something.
I've noticed that hook_submit's return value does nothing, So i was wondering how i could fix this.
Should i change my form action, or is there another solution where the user gets to stay on the same page as where he filled in the form?
Thanks
Comments
If you don't want the
If you don't want the redirection to be happen after submitting the form, place the following code in your custom module...
function newmodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'page_node_form') { // make sure your form_id has given
$form['#redirect'] = false;
}
}
and in your hook_submit() method just place this message drupal_set_message('"Thanks for submitting this form!"'); etc...
Alright, thanks a lot. It's
Alright, thanks a lot.
It's what i needed