0

how to call a drupal node editing form in a custom module? What i have done so far:

/*
 *  implementing hook_menu()
 */

function mymodule_menu() {
  $items = array();

  $items['custompage'] = array(
    'title' => t('Sometitle'),
    'page callback' => 'custom_page',
    'access callback' => 'user_access',
    'type' => MENU_NORMAL_ITEM
  );
  return $items;
}

function custom_page() {
  $output = '';
  $output = drupal_get_form(15);
  return $output;
}

But it won't output node edit form with nid 15. What i am doing wrong?

1 Answer 1

3

15 is the node ID of the node whose edit form you want, not the actual ID of the form. This makes sense since node edit forms are defined per nodetype, not per node.

You'll need to call drupal_get_form() with the form ID, something like [nodetype_name]_node_form.

The second parameter should be the node object, e.g. node_load(15).

2
  • Sorry, i have mistaken i meant drupal_get_form('profile_node_form'), but still it doesn't load it. Commented Oct 19, 2013 at 4:29
  • And are you passing in the node object as the second parameter?
    – beth
    Commented Oct 19, 2013 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.