I've exposed a node_add form and styled it for certain roles to use. The form is being displayed in panels, through an 'article' node type using the PHP text filter. Users can create new nodes with no issues, but there are errors displayed when users try to upload an image in the form:

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 /var/www/html/includes/form.inc).
Notice: Undefined index: #node in comment_form_node_form_alter() (line 1193 of /var/www/html/modules/comment/comment.module).
Notice: Trying to get property of non-object in comment_form_node_form_alter() (line 1210 of /var/www/html/modules/comment/comment.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 629 of /var/www/html/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 629 of /var/www/html/modules/menu/menu.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 630 of /var/www/html/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 630 of /var/www/html/modules/menu/menu.module).
Notice: Undefined index: field_obs_image in file_ajax_upload() (line 271 of /var/www/html/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /var/www/html/modules/file/file.module).

The actual node form code looks like this:

    module_load_include('inc', 'node', 'node.pages');
    $form = node_add('observation');
    print drupal_render($form);

The content type being added is 'observation'. I am also using the identical technique on another page with a different content type, and it results in the exact same error. The error appears directly above the image field during the AJAX image upload call.

I have also done a debug_backtrace() near line 795 of form.inc and can post the results if requested.

Does anyone have an idea as to where I can start looking? This seems to be a tough problem. Thanks for your time!

Comments

mariusilie’s picture

I'm having the same issue with node_add()...

gebjohn’s picture

I'm not clever enough to work out the correct way of fixing this, but I had a similar issue with the file field. The problem is that the form processing stuff tries to call a function that is in the node thing, and it needs including.

Short term botch to show that this is the problem is to add the following line before line 795 in includes/form.inc:
module_load_include('inc', 'node', 'node.pages');

Can somebody who understands this a little more suggest a way to fix this without hacking core? Can it be included using a hook somehow?

kpv’s picture