Hello :)
I am creating a web page. And after submitting the node I need to display a web page saying "Thank you for posting your content!" instead of the node itself.
The task looks simple, but it's not working as I expected. In Drupal 6 I could do
$form['#redirect'] = "somewhere";
but after some gooogling I found out that this was removed in Drupal 7, so now I need to do:
$form_state['redirect'] = "somewhere";
Unfortunately it did not work - after submitting the node form the node was displayed. I had the fallowing code in my module:
/**
* Implementation of hook_form_alter()
*/
function MY_MODULE_form_alter(&$form, &$form_state, $form_id)
{
switch($form_id) {
case 'bylos_node_form':
$form['#submit'][] = '_MY_MODULE_custom_submit';
break;
default:
break;
}
}
/**
* Custom submit handler
*/
function _MY_MODULE_custom_submit($form, &$form_state) {
$form_state['redirect'] = url('thank-you', array('absolute' => true));
}
As I found out that after my custom submit the node_form_submit() (line 404 in node.pages.inc) function is called and after the line
$form_state['redirect'] = 'node/' . $node->nid;
my custom redirect fails.
I could do simpe core hack by replacing the line above with: