I have a content type called 'Checklist' which I bring forward using Views, in it's node-edit form.
I wrote PHP code within the header in order to do this, here it is:
<?php
$view = views_get_current_view();
$arg0 = $view->args[0];
$nodeToLoad = $view->result[0]->nid; //I get the node to load from Fields within my view
module_load_include('inc', 'node', 'node.pages');
$node = node_load($nodeToLoad);
dsm($nodeToLoad);
$edit_page = drupal_get_form('page_node_form', $node);
$edit_page['additional_settings']['#access'] = FALSE;
$edit_page['buttons']['submit']['#submit'][] = 'redirect_submit';
print drupal_render($edit_page );
function redirect_submit($form, &$form_state){
$form_state['redirect'] = 'www.google.com';
}
?>
Now what I want is to add a custom redirect upon saving this particular form.
I've tried this to no avail:
$edit_page['buttons']['submit']['#submit'][] = 'redirect_submit';
print drupal_render($edit_page );
function redirect_submit($form, &$form_state){
$form_state['redirect'] = 'www.google.com';
}
Is it possible to this within the Views header?
Notes:
I have also done this with the Rules module but I'd like to learn if it's possible to do with PHP code in the Views header so I don't split functionality in 2 parts of my project.
This can also be easily done using a custom hook but again, if it's possible to do this within the Views header then that's the trick I'm looking for.
Thanks.