2011-09-30 107 views
0

我正在重构一些代码,是一个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, 
    ); 
可以

任何人请帮助?

回答

3

添加字段集里面,你应该插入域组阵列这里面的表单元素任何形式的元素...

$form['myfieldset'] = array( 
'#type' => 'fieldset' , 
'#collapsible' => TRUE , 
'#title' => t('My FIeldset'), 
'#attributes' => array('id' => 'myfieldset-id'), 
); 

$form['myfieldset']['myradios'] = array(
'#type' => 'radios' , 
'#attributes' => array('id' =>'myradio-attributes') , 
....etc 
); 

所以字段集是收音机的父母不是相反

跳,帮助您

UPDATE:
您可以通过追加使用jQuery为以下

jQuery(document).ready(start) ; 
function start(){ 
    jQuery("#myradio-attributes").appendTo("#myfieldset-id"); 
    // i added this id by '#attributes' 
} 

,但它不是Drupal的方式

设置字段里面的收音机