Drupal模块设置页面构建
我正在重构一些代码,这些代码是我以前编写的 Drupal 模块。为了方便其他人使用,我添加了一个配置页面。
我已经成功定义了一个字段集,但我不知道如何向其中“插入”内容。 以下代码为我的站点上定义的每个节点类型设置单选:
$node_types = node_get_types('names');
$test = array(
'#title' => t('tweeting node'),
'#type' => 'radios',
'#options' => $node_types,
'#default_value' => 'Page',
'#weight' => 0,
);
以下代码定义了我想要将上面生成的单选按钮插入其中的字段集:
$form['twitterhelper_nodecollection'] = array(
'#type' => 'fieldset',
'#title' => t('select a node'),
'#weight' => 0,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#parents' => $test,
);
I am refactoring some code is a Drupal module I wrote sometime age. In order for others to use it, I am adding a configuration page.
I have successfully defined a fieldset but I don't know how to 'insert' content in to it.
The following code sets up radios for each node type defined on my site:
$node_types = node_get_types('names');
$test = array(
'#title' => t('tweeting node'),
'#type' => 'radios',
'#options' => $node_types,
'#default_value' => 'Page',
'#weight' => 0,
);
And the following defines my fieldset into which I want to insert the radio buttons generated above:
$form['twitterhelper_nodecollection'] = array(
'#type' => 'fieldset',
'#title' => t('select a node'),
'#weight' => 0,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#parents' => $test,
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在字段集中添加任何表单元素,您应该将此表单元素插入字段集数组中...
例如
,字段集是无线电的父级,而不是
帮助您
更新:
您可以使用 jquery 将无线电附加到字段集内,如下所示
,但它不是 drupal 方式
to add any form element inside the fieldset you should insert this form element inside the field set array ...
E.g
so the fieldset is the parent of the radios not the contrast
hop that help you
UPDATE:
you can append the radios inside the field set by using the jquery as the following
but its not the drupal way