【问题标题】:drupal 6 radios button group checked attributedrupal 6单选按钮组选中属性
【发布时间】:2012-04-02 10:48:24
【问题描述】:

我知道这可能是一个非常简单的解决方案,但我正在努力实现它。我需要在同一组的两个单选按钮之一中添加一个选中的属性。 这是我的代码:

$options = array(
'yes'=>t('Yes'),
'no'=>t('No')

);
$form['checklist_fieldset']['heating'] = array(
   '#type' => 'radios',
   '#title' => t('Heating options'),

   '#options' =>$options,
  '#default_value'=>$options['yes'],
  );

当我提交表单时,我得到的是默认值,但对于用户,我需要将其显示为已选中。我怎样才能实现它?

【问题讨论】:

    标签: drupal drupal-6 drupal-modules drupal-fapi drupal-forms


    【解决方案1】:

    试试这个

    $options = array(
    'yes'=>t('Yes'),
    'no'=>t('No')
    );
    
    $form['checklist_fieldset']['heating'] = array(
       '#type' => 'radios',
       '#title' => t('Heating options'),
    
       '#options' =>$options,
      '#default_value'=>'yes',
      );
    

    【讨论】:

      猜你喜欢
      • 2011-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      • 2011-04-06
      • 1970-01-01
      • 2016-08-29
      相关资源
      最近更新 更多