Closed (fixed)
Project:
Documentation
Component:
Correction/Clarification
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
17 Dec 2007 at 17:29 UTC
Updated:
1 Sep 2011 at 12:57 UTC
I'm running into a problem creating a node on a non-node page using drupal_execute();. Here's the error:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in C:\htdocs\drupal6\includes\form.inc on line 340.
I know that node_form(); can be found in the node.pages.inc file, which appears to not be included because:
drupal_retrieve_form();)So, my question is whether there's a way to get this file included without implicitly including it with something like:
require_once drupal_get_path('module', 'node') . '/node.pages.inc');
Should this re-classified as a bug?
-Fractile81
Comments
Comment #1
asimmonds commentedI think drupal_execute() is somewhat of a edge case at the moment, it works but you have to be somewhat aware of what other code is required for the form to work properly, anyways I'm successfully using drupal_execute() to create content from within my install profiles for 6.x.
I use:
then the usual:
to create the node.
Comment #2
mpare commentedI'm running into similar issues using drupal_get_form, also effecting node_add, node_page_edit, etc... I'm still looking to see if I'm doing something stupid or if there really is an issue here.
Comment #3
mpare commentedComment #4
fractile81 commentedSo, yeah, I suppose that's the question, do we:
1) Do the module_load_include(); as asimmonds suggests (I like that a lot better than how I did it), or
2) Should form functions, as a standard, be pulled into the main module function for the sake of drupal_execute();?
As D6 is now in RC1, it might be a little late in the game for #2 to happen, mandating #1 for now. However, this might be something good to push into the D7 arena. Any thoughts on this would be appreciated!
Comment #5
fractile81 commentedOops, cross-posted.
Comment #6
mpare commentedI don't think that this is really a core issue but a documentation issue for d.o. I'm updating node 114774, Converting 5.x Modules... to reflect this necessary step for loading node forms from third party modules. I'm also changing the issue to reflect this. I think this is part of the new optimization practices implemented in D6 but can't say that with 100% confidence that's just the obvious explanation. Also a change to the above posted code.
should probably read
According to the api docs and out of the simple fact that it doesn't work.
If the change of status of this issue is incorrect please feel free to revert.
-mpare
Comment #7
mpare commentedI've updated the Module Conversion guide to reflect these new changes, http://drupal.org/node/114774#module_load_include.
Comment #8
shunting commentedThanks. This was driving me nuts.
mpare @7, a small editorial tweak?
Now:
A common use for this implementation is when a custom module needs to load a node form
Suggested:
A common use for this implementation is when a custom module needs to load a node form (for example, via drupal_execute) ...
Now drupal_execute will show up in a search....
Comment #9
shunting commentedBut don't we have a documentation bug in form.inc? This definitely makes drupal_execute look like a normal thing to do, and not at the bleeding edge.
This:
Should become this?
Comment #10
mpare commentedI don't really think there is a bug in that specific location. If there is a documentation bug in core for this issue I believe it is probably in CHANGELOG.txt and that's if there is one. See this issue is much broader than just forms or node functions it pertains to the entire drupal core anytime you are needing to use functionality contained in a specialized include file. I dare not dictate this issue alone and other feed back from others is more than welcome and even encouraged.
Comment #11
alanmackenzie commentedsubscribing.