Drupal 7 中的节点/内容类型不显示表单
我正在尝试在 drupal 中创建节点/内容类型,因此我至少有一个 .info、.install 和 .module 文件。
该模块创建得很好,我可以从模块管理页面启用/禁用它,而且,Drupal 能够将该模块识别为内容类型,并且当我在内容菜单中单击“添加内容”时它会出现。
一切正常,但它不显示表单元素,而是直接从
表单元素代码 开始下面列出:
function newNode_form($node,&$form_state)
{
$type = node_get_types('type',$node);
$form['title']= array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#default_value' => !empty($node->title) ? $node->title : '',
'#required' => TRUE,
'#weight' => -5,
);
$form['field1'] = array(
'#type' => 'textfield',
'#title' => t('Custom field'),
'#default_value' => $node->field1,
'#maxlength' => 127,
);
$form['selectbox'] = array(
'#type' => 'select',
'#title' => t('Select box'),
'#default_value' => $node->selectbox,
'#options' => array(
1 => 'Option A',
2 => 'Option B',
3 => 'Option C',
),
'#description' => t('Choose an option.'),
);
return $form;
}
任何人都可以告诉我出了什么问题
P.S:仅供参考:在我的 .install 文件中,仅存在安装和卸载挂钩函数。我尚未创建数据库表,此内容类型是我创建内容类型 UI 的演练,不一定是完整的 UI。
I am attempting to create a node/content type in drupal, accordingly I have a .info, .install and .module file at minimum.
The module is created fine and I am able to enable/disable it from the module administration page, also, Drupal is able to recognize this module as a content type and it appears when I click 'Add content' in the Content menu.
Everything works fine, but it does not show the form elements, rather it starts directly at
The form element code is listed below:
function newNode_form($node,&$form_state)
{
$type = node_get_types('type',$node);
$form['title']= array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#default_value' => !empty($node->title) ? $node->title : '',
'#required' => TRUE,
'#weight' => -5,
);
$form['field1'] = array(
'#type' => 'textfield',
'#title' => t('Custom field'),
'#default_value' => $node->field1,
'#maxlength' => 127,
);
$form['selectbox'] = array(
'#type' => 'select',
'#title' => t('Select box'),
'#default_value' => $node->selectbox,
'#options' => array(
1 => 'Option A',
2 => 'Option B',
3 => 'Option C',
),
'#description' => t('Choose an option.'),
);
return $form;
}
Can anybody tell me what's wrong
P.S: Just F.Y.I: In my .install file, there exists only install and uninstall hook functions. I have yet to create DB tables, this content type is a walkthrough for me to create content type UI and not necessarily a full blown UI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Drupal 的钩子系统使用小写字母和小写字母来动态加载模块函数。
尝试像这样声明你的函数:
Drupal's hook system uses lower cases and under scores to dynamically load module functions.
Try declaring your function like this: