希望我能正确理解您的问题。我的评论的答案确实有帮助!如果它是您尝试添加到菜单的节点表单,这通常通过 Drupal 中的 hook_menu() 函数来完成。这里有一些示例代码可以帮助您入门
function YOURMODULE_menu() {
// Here, substitute in the URL of your page. It can be mymodule/add_content or whatever else you'd like
$items['YOUR_PAGE_URL'] = array(
'type' => MENU_CALLBACK,
'title' => t('YOUR PAGE TITLE'),
'page callback' => 'drupal_get_form',
'page arguments' => array('your_node_function'), // Here, you should put in the function that creates your node form
'access arguments' => array('Administer content'), // This is optional, you can require a user to have certain permissions set to access your page/form
);
return($items);
}
记得在测试之前清除缓存!
创建表单的函数中的示例代码:
function your_node_function($form, &$form_state)
{
$form['field_1'] = array(
'#type' => 'textfield',
'#title' => t('Field label'),
'#description' => t('Help user understand what to input here'),
'#required' => TRUE,
);
return $form;
}
看看你能不能看到这个小小的单字段表单来帮助你开始。这并没有解释如何实际保存用户数据等,因为这超出了此处单个答案可以提供的范围,但这应该可以帮助您开始使用与菜单系统相连的表单......
希望对你有帮助!!!!
=================== 编辑===================
这里是您可以在 Drupal 中添加到表单的不同类型表单元素的在线文档:http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7