1

Possible Duplicate:
D7 Image field upload errors with custom node_add() form

I have a custom page with a node form on it. The problem is that when I try to upload an image I get lots of errors.

The code is like this:

module_load_include('inc', 'node', 'node.pages');
$output = drupal_render(node_add('node_type'));
return $output;

Some of the errors I get are:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in drupal_retrieve_form() (line 795 of E:\work\my_site\includes\form.inc).
Notice: Undefined index: #node in comment_form_node_form_alter() (line 1193 of E:\work\my_site\modules\comment\comment.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 630 of E:\work\my_site\modules\menu\menu.module).

The funny thing is that if I return the form array everything works well.

module_load_include('inc', 'node', 'node.pages');
$output = node_add('node_type');
return $output;

Unfortunately this doesn't help me at all.

This is the same problem as in here but the solution there is not an option for me.

Any ideas? Thanks

marked as duplicate by kiamlaluno Jun 28 '12 at 13:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7

Yeah, apparently you should add these line to the menu item array:

'file path' => drupal_get_path('module', 'node'),
'file' => 'node.pages.inc',

it is not enough to just add module_load_include('inc', 'node', 'node.pages'); before printing the form.

  • This solved the problem for me! I was also able to remove the module_load_include('inc','node','node.pages'); line from my page callback, it was no longer needed. – Professor Falken Mar 2 '15 at 17:31

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