0

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

2 Answers 2

2

If you have a white page then there is very likely an error somewhere. Check your apache or php error logs. Which could really be any where depend on what platform you are developing on.

Fatal errors won't make it into the database log file within Drupal since fatal errors tend to stop everything dead.

1
  • I get nothing in the PHP error log. But in the Apache log I found [Fri Aug 12 11:53:38 2011] [notice] child pid 8421 exit signal Segmentation fault (11) Commented Aug 12, 2011 at 10:41
0

This is so late... Hope it helps someone... I had the same problem with a white page and no errors reported.

In the form function you need need to return drupal_get_form(

I was simply calling drupal_get_form( and not returning it and had the exact same problem.

1
  • 1
    Hi and welcome to Druapl Answers. Thanks for the answer, could you please edit it and elaborate.
    – Wtower
    Commented Jul 17, 2014 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.