i have the code in template.php:
THEMENAME_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'answer_node_form' && !isset($form['nid']['#value'])) { //dpm($form); // redirect after we created a new node $form['actions']['submit']['#submit'][] = 'node_reference_redirect'; } elseif ($form_id == 'answer_node_form' && isset($form['nid']['#value'])) { // redirect after we have made changes to a node - node/17/edit $form['#submit'][] = 'node_save_reference_redirect'; } } function node_reference_redirect($form, &$form_state) { $form_state['redirect'] = 'node/' . arg(1); } function node_save_reference_redirect($form, &$form_state) { $form_state['redirect'] = '/index.php';//$form['field_answer']['und'][0]['nid']['#default_value']; }
function named node_reference_redirect() works as expected – it redirects after creating a new node: node/add/content-type, but the 2nd redirect – when we are doing changes to an existing node: node/[nid]/edit, when we press “save” it doesn’t redirects to a index.php for example… Can’t figure out what’s wrong. Any ideas? Thanks