Drupal 7 hook_node_view add a form to the content of a node

前端 未结 2 1490
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-15 14:33
function example_module_node_view($node, $view_mode, $langcode)
{   
    $f =  drupal_get_form(\'example_module_form\', $node);
    $node->content[\'data_collection_f         


        
2条回答
  •  再見小時候
    2021-02-15 15:27

    Clive answer doesn't work in my case. I needed to call drupal_render and pass it as markup.

    $form = drupal_get_form('example_module_form', $node);
    $node->content['data_collection_form'] = array(
      '#markup' => drupal_render($form),
      '#weight' => 10,
    );
    

    This work, but I'm not sure if this is the correct way.

提交回复
热议问题