I create a page , the input format is php code .

content:

  global $user;
  $type ='page';
  $types = node_get_types();
  $nodex = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => ''); 
  drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));  
  $output = drupal_get_form( $type . '_node_form', $nodex); 
  echo $output ;

But view it , show:

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:\wamp\www\projects\drupaltest\includes\form.inc on line 366.

How can I get create content form in my custom page ?

Comments

zbricoleur’s picture

...but if it helps, your code works flawlessly on my site.

panhongwei’s picture

What drupal version ?
thank you?

zbricoleur’s picture

6.4

heine’s picture

You need to include node.pages.inc before you can call drupal_get_form($type ...); as the form builder (node_form) and a lot of other important node form functions are in that file.

Then a general tip: make a custom module to hold this code and minimize the use of PHP nodes.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.

tomrenner’s picture

This has solved my prob, too!

panhongwei’s picture

I can't run it .
Please show your code , thank you!

alpha2211’s picture

I believe Heine is referring to;

module_load_include('inc', 'node', 'node.pages');

use this before you make your call to drupal_get_form

panhongwei’s picture

I can run it !
Thank you very much!

lukas.fischer’s picture

$new_blognode = new stdClass();
$new_blognode->type = 'blog';
module_load_include('inc', 'node', 'node.pages');
$output .= drupal_get_form('blog_node_form', $new_blognode);

works for me!

all the best
Lukas

--
www.netnode.ch