I want to know why node not save if I use drupal_goto in the end of form_submit function , it redirect to my page but the node not saved !!!

function mm_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == "pre_register_node_form") {
 $form['#submit'][] = 'mm_submit_redirect';

function mm_submit_redirect(&$form, &$form_state) {
  • For that it would be better if you provide your submit function. How would we guess what is going wrong otherwise ;-) – AjitS May 19 '14 at 5:02
  • @AjitS you can think I only wrote drupal_goto('myhpath'); in form_submit – Yuseferi May 19 '14 at 5:06
  • @zhilevan not enough info Provided. When you ask for help tell us what you did already. – niksmac May 19 '14 at 5:24
  • In a custom form? in a form_alter of the node form? Without writing node_save. Couldn't figure that out on my own. – AjitS May 19 '14 at 5:25
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – niksmac May 19 '14 at 5:25

See internally when you save any node in drupal number of submissions comes to place. And once you will use drupal_goto, it will stop the process there, redirect you and will not execute rest of required functions. There is possibility where you are using drupal_goto function in your code, other submit handlers might be required in order to things work properly. If you call drupal_goto you would stop the execution flow and make it impossible for the other submit handlers to finish their thing. Now there is two way either you use some another approach for redirection or make sure your redirect submit handler (drupal_goto) is last.

I would suggest, you should use $form_state['redirect'] instead of drupal_goto. Once I was using this function in my code and due to this automated cron stopped working, so I would recommend you avoid this function until you dont have other option because there is chance other submit handlers could be skipped, if this function not used properly.

Use $_GET['destination']=$redirect_url; instead of $form_state['redirect']=$redirect_url;.

| improve this answer | |

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