drupal_get_form won't print the add node form
Im trying to get drupal_get_form('ccknode_node_form') to work, but nothing prints.
I've tried for example drupal_get_form('user_register'), and that works.Im sure its very simple problem, but i 开发者_开发问答really need som help with this.
Thanks /AndersThe node_form
is located in node.pages.inc
which is what you are missing. If you add
module_load_include('inc', 'node', 'node.pages');
that should fix it.
I am also having problems with drupal_get_form but the code below will return the form html. Problem areas can be not calling the correct node_form.
function get_author_form() { //return node_form(NULL,NULL); //return drupal_get_form('author_form'); return author_ajax_form('author'); } function author_ajax_form($type) { global $user; module_load_include('inc', 'node', 'node.pages'); $types = node_get_types(); $type = isset($type) ? str_replace('-', '_', $type) : NULL; // If a node type has been specified, validate its existence. if (isset($types[$type]) && node_access('create', $type)) { // Initialize settings: $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => 'bbb','bbb' => 'TRUE'); $output = drupal_get_form($type .'_node_form', $node); } return $output; }
Hi @andersandersson666,
As @googletorp said, you need to include the node.pages from node module as they said:
module_load_include('inc', 'node', 'node.pages');
Then, you need to use a new function in Drupal 7 to get the form:
$theFormHTMLified = drupal_render(node_add("ccknode"));
Now you can print or return the $theFormHTMLified
.
Hope it helps
精彩评论