在fieldset中添加复选框

时间:2015-02-14 11:59:39

标签: drupal drupal-7 drupal-modules

我有这个字段集和这些复选框......

function repository_search_filter_form($form, &$form_state){ 

        $form['global_fieldset_container']['global_fieldset_by_metadata'] = array (
            '#type' => 'fieldset',
            '#title' => t('By Metadata'),
            '#collapsible' => '1',
            '#weight' => '99',
            '#tree' => true,
            '#collapsed' => 'true',
        );

         $form['global_fieldset_container']['global_fieldset_by_case_study'] = array (
                    '#type' => 'fieldset',
                    '#title' => t('By case study'),
                    '#collapsible' => '1',
                    '#weight' => '99',
                    '#tree' => true,
                    '#collapsed' => 'true',
                );

                $by_casestudy_options = array(
                     '1' =>'option1',
                     '2' => 'option2',
                 ); 

                }

                $form['global_fieldset_container']['global_fieldset_by_case_study']['bycasestudy'] = array(
                    '#type' => 'checkboxes',
                    '#options' => $by_casestudy_options
                );

    return $form;
        }

我想在fieldset" global_fieldset_by_metadata"添加一些动态复选框,但在回调函数....

function ajaxforms_basic_callback($form, $form_state) { 
 $commands = array();
 $form_filter = drupal_get_form('repository_search_filter_form');

        $by_metadata_options = array(   
                    '1' => 'Metadata1',
                    '2' => 'Metadata2',  
        );

        $form_filter['global_fieldset_container']['global_fieldset_by_metadata']['bymetadata'] = array(
                        '#type' => 'checkbox',
                        '#options' => $by_metadata_options,

        );

       $form_filter = drupal_render($form_filter);

   $commands[] = ajax_command_replace(".filter", $form_filter);

}

但结果是一个空的复选框......

PS。我试过了"复选框" in" #type"但我没有结果在fieldset。

0 个答案:

没有答案