0

I have created custom submit form handler for entity using below

$form['#submit'][]='app_contact_form_submit_message_alter';

but when i used

drupal_get_messages($type = NULL);
drupal_set_message('Thanks for your feedback we will contact soon.');
drupal_redirect_form($form_state);

It redirect correctly but entity is not created.

and even if i use drupal_goto() same thing happening.

1
  • As side note, the name of the submission handler could potentially conflict with a hook implementation of hook_form_FORMID_alter() done for a form with ID equal to submit_message.
    – avpaderno
    Commented Dec 29, 2014 at 5:08

1 Answer 1

2

If you want to redirect a form submit you should use the redirect parameter:

function app_contact_form_submit_message_alter(&$form, &$form_state) {
  drupal_get_messages($type = NULL);
  drupal_set_message('Thanks for your feedback we will contact soon.');
  $form_state['redirect'] = 'node/23'; // The path you want to go
}

This will call drupal_redirect_form($form_state) byt its self, if you call it directly you are skipping the save step.

More info: https://api.drupal.org/comment/18139#comment-18139

Your Answer

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

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