The Field module shows an error when I call drupal_get_form() I have a menu local task callback in hook_menu():

$items['leg/add'] = array(
    'title' =&gt; t('Create a new leg'),
    'page callback' =&gt; 'mymodule_leg_node_form',
    'access arguments' =&gt; array('create leg content'),      
    'file' =&gt; 'node.pages.inc',
    'file path'=&gt; drupal_get_path('module', 'node'),
    'type' =&gt; MENU_LOCAL_TASK,
    'weight' =&gt; 2,
);  


This is the page callback function:

function mymodule_leg_node_form(){
    $form = drupal_get_form('leg_node_form');
    return $form;
}


When I visit that page, I get the following error:


  Fatal error: Cannot access empty property in path\to\site\modules\field\field.attach.inc on line 197


I have a "Leg" content type, and I just want to show the form to create nodes of that type in a tab.  

My content type has two fields: "field_from" and "field_to."
drupal_get_form() calls _field_invoke(), and the error is generated from that function.

I tried to change the menu definition as below, but I get the same error.

$items['leg/add'] = array(
    'title' =&gt; t('Create a new leg'),
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('leg_node_from'),   
    'access arguments' =&gt; array('create leg content'),      
    'file' =&gt; 'node.pages.inc',
    'file path'=&gt; drupal_get_path('module', 'node'),
    'type' =&gt; MENU_LOCAL_TASK,
    'weight' =&gt; 2,
);


I'm implementing something similar to what reported in http://drupal.org/node/251526#comment-827860; it might work in Drupal 6 with the CCK module, but it doesn't seem to work on Drupal 7.

I found the same problem reported in Drupal bug issues, but I could not find any qualified answer.


http://drupal.org/node/1015580#comment-4914818  
http://drupal.org/node/1028230#comment-4799746
Solved this issue when I upgraded to drupal 7.10, but I had to create a node object in the page callback function.

function mymodule_leg_node_form(){
    global $user;
    global $language;

    $node = new stdClass();
    $node-&gt;uid = $user-&gt;uid;
    $node-&gt;type = 'leg';
    $node-&gt;language = $language-&gt;language;

    $form = drupal_get_form('leg_node_form', $node);
    return $form;
}