I have a menu local task callback in hook_menu()
:
$items['leg/add'] = array(
'title' => t('Create a new leg'),
'page callback' => 'mymodule_leg_node_form',
'access arguments' => array('create leg content'),
'file' => 'node.pages.inc',
'file path'=> drupal_get_path('module', 'node'),
'type' => MENU_LOCAL_TASK,
'weight' => 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' => t('Create a new leg'),
'page callback' => 'drupal_get_form',
'page arguments' => array('leg_node_from'),
'access arguments' => array('create leg content'),
'file' => 'node.pages.inc',
'file path'=> drupal_get_path('module', 'node'),
'type' => MENU_LOCAL_TASK,
'weight' => 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.