I'm building a module for basic e-mail sharing that will present a form on every node. So I hook into nodes and add a new variable called share_form
which is supposed to contain the from from email_share_node_form
after it has been fetched with drupal_get_form
.
I have been checking out loads of examples and as far as I can see I'm doing everything right. But the page turns completely blank, with no errors either in the reports or on the page. The same occurs when I use other form_ids such as user_register_form
that is supposed to work.
If I add any normal string to share_form
the page renders with no issues at all. So the error is definitely occuring inside drupal_get_form
.
Is there obvious error in my code? How can I debug this?
UPDATE: If I put the render(drupal_get_form('email_share_node_form'))
in my node.tpl.php
it renders just fine. Why not in the module?
/**
* Hook into node_load to insert an e-mail share form.
*/
function email_share_node_load($nodes, $types) {
foreach ( $nodes as $nid => $node ) {
$nodes[$nid]->share_form = drupal_get_form('email_share_node_form');
}
}
// --------------------------------------------------
/**
* Create a share-form to display on a node.
*/
function email_share_node_form($form, &$form_state) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
return $form;
}
Thanks