1

I have a very similar functionality to stackoverflow - i.e. I have a a view that display question and below it there are answers (seperate nodes references).

Currently, in order to add new answer to the question, the user has to click on a link, which takes him to add node form. But I need to display the form below the view, so the user can answer without being redirected to add node form on a seperate page. I guess it can be done programatically using drupal_get_form() function, but I have no idea how to start. Can anyone give me any suggestion or tutorial? Or maybe there is module for that..? Any advice is greatly appreciated.

0

2 Answers 2

2

Don't worry, there's a module for that! http://drupal.org/project/formblock I believe this can work with node-references with a bit of configuration. If not, you can use this tutorial to populate the node reference: http://grayside.org/comment/830 which should get carried over by the FormBlock module.

1

I'm using the following code to load an empty node creation form:

//create empty node and build node edit form
    module_load_include('inc', 'node', 'node.pages');
    $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => 'player', 'language' => LANGUAGE_NONE, 'title' => ''); 
    $player_form = drupal_get_form('player_node_form', $node);
1
  • I tried to include it in the php footer, but it doesnt display anything. I've changed player to answer...
    – Vonder
    Commented Nov 10, 2011 at 17:09

Your Answer

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

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