Hi,
I have an existing node which has additional fields.

Now I want to add a form programmatically to its "body".
To be clear: its just for a single node and not to all nodes of that type.

Which is the best way?

Comments

dotpex’s picture

hardcode solution:

function my_module_node_view() {
 if ($node->nid == 12345) {
  $node->content['my_form'] = array(
    '#markup' => drupal_render(drupal_get_form('my_custom_form')),
    '#weight' => 5,
  );
 }
}
premier23’s picture

thanks for the answer.

Is it possible to inject the form in the body-field?

dotpex’s picture

function my_module_node_view($node, $view_mode, $langcode) {
 if ($node->type == 'article' && $view_mode == 'full') {
  $node->content['body'][0]['#markup'] .= drupal_render(drupal_get_form('my_custom_form')),
 }
}