I am trying to have a submitted form go to a specific page.

...
$form['#action'] = url("/");
...

I am using the redirect on a node/add page. The above code redirects properly, however, the form does not add a node. I do not get a drupal_message saying the node was added either. Any thoughts on this?

Comments

nevets’s picture

#action controls the processing of a form, change it and the default processing does not happen. It sounds like you want to use #redirect.

greylogic’s picture

A node will be created only if the submit function of the form gets called. This usually happens when drupal_get_form () is invoked for the same form with $_POST data.

In your case, If you want the user to be redirected to a different page after node creation, try manipulating the $form['#redirect']. The node module sets this to node/[newly-created-node-id]

use hook_form_alter and set this to drupal path of your liking.

--------------------------------------------------------------
My attempt with Drupal - Jaanlo.com

theabacus’s picture

Thanks, worked excellently.