2012-03-08 72 views
0

我試圖放在一起將有它自己的配置頁面的模塊。爲此,我使用下面的代碼作爲我的菜單頁面回調:Drupal 7 hook_menu複選框問題

function webform_customizations_customize() { 
    $form = array(); 
    // Text field for the e-mail subject. 
    $form['webform_customizations']['user_warn_e-mail_subject'] = array(

     '#type' => 'textfield', 
     '#title' => t('Warning e-mail subject'), 
     '#description' => t('The subject of the e-mail which will be sent 
    to users.'), 
      '#size' => 40, 
      '#maxlength' => 120, 
      '#required' => TRUE, 
    ); 
    $options = array('A', 'B', 'C'); 
    $form['test'] = array(
     '#type' => 'radios', 
     '#options' => array(
       'one' => t('one'), 
       'two' => t('two'), 
      ), 
     '#title' => t('roles that should see a minimal webforms setting area'), 
     '#title_display' => t('testing'), 
    ); 
    $form['high_school']['tests_taken'] = array(

    '#type' => 'checkboxes', 

    '#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))), 
    '#title' => t('What standardized tests did you take?'), 
    '#states' => array(
     'visible' => array(// action to take. 
     ':input[name="student_type"]' => array('value' => 'high_school'), 
    ), 
    ), 
); 
return $form; 
} 

道歉長碼。

我的問題是我嘗試顯示覆選框失敗。第一個字段成功顯示文本字段。但接下來的兩個是從未在我的配置頁面上顯示的複選框,並且tests_taken複選框代碼直接從this drupal doc page中解除,沒有任何修改。

我試過一個複選框,並且工作正常。

請幫忙。

回答

0

你應當已經閱讀同着你把代碼沿着評論:

// This #states rule says that this checkboxes array will be visible only 
    // when $form['student_type'] is set to t('High School'). 
    // It uses the jQuery selector :input[name=student_type] to choose the 
    // element which triggers the behavior, and then defines the "High School" 
    // value as the one that triggers visibility. 

只要簡單地除去#states元素,它應該工作。 快樂打扮!