Hello,
I made a module with two node types. One type is the parent type and the other is the children type. When creating a children type you have to choose the parent onde. The normal procedure is to use the hook_form to create a custom node form. And add a selection to let the user choose the right parent when creating a child node. Buy I don't like this method as there can be many parent nodes and choosing the right one is anoying. You have to remember the correct title of the desired parent. I fond it much easyer to create a hook_menu for the parent type node and add a "Add child" MENU_LOCAL_TASK, then get the children type form with drupal_get_form, and prefill the values with the current node id. This way the users just have to browse the parents nodes and click where the want to add child.
The problem with my implementation is that I cannot get the node form from the hook_menu of my module. The node forms require to include the node.pages.inc. I cannot define 'file' -> 'node.pages.inc' in my menu as drupal search in the module directory and not in others modules directories. An another solution would be to create custom forms with hook_forms and call these forms. But these forms would not heritate the node forms properties, and would require to copy many parts of the node form system.
So is there a better way to implement this prefilled node creation form ?
Help would be greatly appreciated,
Thanks.
Comments
Here is a piece of code that
Here is a piece of code that reproduce my problem :
and the error I get :
This second type of
This second type of get_n_prefill_form function is a partial copy of node_add function and make a direct call to test_form function to avoid the drupal_get_form problem.
This provoques a similar error :
Of course we always get the same problem. We need a function that is in node.pages.inc that is not reachable. So how can I do the thig working ? Drupal should be able to do this simple process. Were I did wrong ?
Help !
The answer was : "use 'file
The answer was : "use 'file path' => drupal_get_path('module', 'node')" :