I want to implement the create content form programmatically. In hook_menu()
I have the following code.
$items['create/content/video'] = array(
'title' => 'Create Video',
'page callback' => 'create_content_video',
'access arguments' => array('create video'),
'type' => MENU_LOCAL_TASK,
'weight' => 1
);
In hook_init()
, I have the following code.
if (arg(0)=='node' && arg(1)=='add') {
drupal_goto('create/content/'.arg(2));
}
In hook_theme()
, I have the following code.
'video_node_form' => array(
'arguments' => array(
'form' => NULL,
),
'template' => 'my_theme_video_form',
'render element' => 'form',
),
In the page callback, I have the following code.
function create_content_video() {
module_load_include('inc', 'node', 'node.pages');
return node_add('video');
}
In the template file, I render form element correctly. My problem is with the the AJAX uploader in the form. Without, I use the upload button to upload the file, and the node is correctly saved; when I use the AJAX uploader, it returns an error.
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/mysite/includes/form.inc).
Notice: Undefined index: #node in comment_form_node_form_alter() (line 1193 of /var/www/mysite/modules/comment/comment.module).
Notice: Trying to get property of non-object in comment_form_node_form_alter() (line 1210 of /var/www/mysite/modules/comment/comment.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 629 of /var/www/mysite/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 629 of /var/www/mysite/modules/menu/menu.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 630 of /var/www/mysite/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 630 of /var/www/mysite/modules/menu/menu.module).
Notice: Undefined index: #node in translation_form_node_form_alter() (line 135 of /var/www/mysite/modules/translation/translation.module).
Notice: Trying to get property of non-object in translation_form_node_form_alter() (line 135 of /var/www/mysite/modules/translation/translation.module).
Notice: Undefined index: type in xmlsitemap_node_form_node_form_alter() (line 136 of /var/www/mysite/sites/all/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module).
Notice: Undefined index: nid in xmlsitemap_node_form_node_form_alter() (line 136 of /var/www/mysite/sites/all/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module).
Notice: Undefined index: field_news_attachment in file_ajax_upload() (line 276 of /var/www/mysite/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 285 of /var/www/mysite/modules/file/file.module).
When I create content without this method, it works fine.
I am using Drupal 7.14.