How to display node/add/sometype form on another page?

后端 未结 9 976
故里飘歌
故里飘歌 2020-12-07 22:41

The whole problem is following:

Lets say we have Items, Items can have Bids, Items can have Questions and Question can have Answer.

When an Item is displayed

相关标签:
9条回答
  • 2020-12-07 23:30
    // Drupal 7    
    // Embed node creation form on a custom page inside module.
    module_load_include('inc', 'node', 'node.pages');
    $form = node_add('node_machine_name'); 
    return drupal_render($form);
    
    0 讨论(0)
  • 2020-12-07 23:30

    Thomas's answer looks good to me: Formblocks and perhaps automatic nodetitles. I think you could expand on that with Nodereference URL Widget -- using nodereferences rather than comments, and letting that module do the work of keeping child-nodes connected to their parent.

    0 讨论(0)
  • 2020-12-07 23:34

    I am reproducing the solution which worked for me on my case. it is available as an answer on Drupal.org and it may help others with the same problem I was experiencing.

    The answer is available here: https://www.drupal.org/node/1336212#comment-6192404.

    I am copying-pasting it below:

    in your custom callback OR in a hook_form_alter, call either...

    <?php
    form_load_include($form_state, 'inc', 'node', 'node.pages');
    ?>
    

    ...OR...

    <?php
    form_load_include($form_state, 'inc', 'user', 'user.pages');
    ?>
    

    ...depending on whether the core Drupal form you're loading is a node form or a user form.

    0 讨论(0)
提交回复
热议问题