Drupal_get_form will not print node add form

I am trying to get drupal_get_form ('ccknode_node_form') to work, but it doesn't print anything.
I tried for example drupal_get_form ('user_register') and it works.

I am sure this is a very simple problem, but I really need help. Thanks
/ Anders

+3
source share
3 answers

node_formis in node.pages.incwhat you are missing. If you add

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

which should fix it.

+2
source

I am also having problems with drupal_get_form, but the code below will return the html form. Problem areas may not cause 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;
}
0

@andersandersson666,

As @googletorp said, you need to include node.pages from the node module, as they said:

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

Then you need to use the new function in Drupal 7 to get the form:

$theFormHTMLified = drupal_render(node_add("ccknode"));

Now you can print or return $theFormHTMLified.

Hope this helps

0
source

Source: https://habr.com/ru/post/1740918/


All Articles