Today's Deals (in Amazon.com)

 Question:

7 - Render a drupal form retrieved by drupal_get_form
  • Kevin

    In Drupal 7, I have a preprocess function retrieving a form like so:

    $contact = drupal_get_form('privatemsg_new');
    

    $contact is then a fully populated form array with the right fields and elements. After that, I tried drupal_render and render, but neither one show a themed output in the node. What do I have to do to display the form?

  •  Answers:

  • googletorp

    The correct answer is to use drupal_render, which is used for render arrays like the form is. I tested this with a different form, and got the desired result so what you're doing should be right. Most likely you have a different error some where in your code causing this.

    $html = drupal_render(drupal_get_form('form_id', $args)));