2011-09-30 113 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的方式

設置字段裏面的收音機