When I add a form to a node's render tree using hook_node_view()
, eg
<?php
/**
* Implements hook_node_view().
*/
function MODULE_node_view($node, $view_mode, $langcode){
if ($node->nid == 9 && module_exists('contact')) {
module_load_include('inc', 'contact', 'contact.pages');
$cForm = drupal_get_form('contact_site_form');
//$cForm['#action'] .= '?destination=' . request_path();
$node->content['contact_form'] = array(
'#markup' => drupal_render($cForm),
'#weight' => 20,
);
}
}
then I get my messages displayed right after the submission.
I do the same thing with template_preprocess_node()
, the messages are displayed one request after the submission.
I suspect this is related to the execution order. Can someone shed some light on the difference here?