I already have a node created with some custom fields, I would like to show a specific form in the detail page of the node that i created (using the node.tpl.php file)

Why? because I need to use some values of the node to custom parts of that form

What's the cleanest way to do this?

  • There are a number of different ways - what are your criteria for "clean"/"best"/etc?
    – Clive
    Apr 5, 2017 at 15:51

1 Answer 1


The best way to do it is to create a variable for your template in hook_preprocess_node():

function hook_preprocess_node(&$vars)
  $form = drupal_get_form('form_name');
  $vars['my_form'] = render($form);

Now you can drop the form anywhere in your template as the variable $my_form

Your Answer

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

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