我正在尝试使用Drupal表单来显示复选框,但我似乎没有运气。
function multi_reg_pagecreate() {
$multi_reg_checkbox = multi_reg_checkbox();
print_r($multi_reg_checkbox);
$form['multi_reg_checkbox'] = array(
'#type' => 'checkboxes',
'#options' => $multi_reg_checkbox,
'#description' => t('Register for multiple events here')
);
return $form;
}
数据采用以下格式:
Array ( [22] => Test Event Reg [23] => Test Event Reg 2 )
这与示例中的内容类似:
https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/6#checkbox
我做得不对?
编辑:
我在显示的页面上看到了这一点:
<form id="multi-reg-pagecreate" accept-charset="UTF-8" method="post" action="/domain/multiple-registration">
<div>
<div class="form-item form-type-checkboxes form-item-multi-reg-checkbox">
<label for="edit-multi-reg-checkbox">Events </label>
<div id="edit-multi-reg-checkbox" class="form-checkboxes"></div>
<div class="description">Register for multiple events here</div>
</div>
<input type="hidden" value="form-t_KSPV9ULp71yMEUHCtDUKV4R3M18M4ie2_M6cj-ZVU" name="form_build_id">
<input type="hidden" value="RzzEFjyCz29CjH9F9PAB5UV9Xq9VBCx8mTY_HppLfiA" name="form_token">
<input type="hidden" value="multi_reg_pagecreate" name="form_id">
</div>
</form>
答案 0 :(得分:2)
function multi_reg_pagecreate($form, &$form_state) {
$multi_reg_checkbox = multi_reg_checkbox();
$form['multi_reg_checkbox'] = array(
'#title' => t('Events'),
'#type' => 'checkboxes',
'#options' => $multi_reg_checkbox,
'#description' => t('Register for multiple events here')
);
return $form;
}
修改强>
选项必须如下:
'#options' => array (
0 => t('Monday'),
1 => t('Tuesday'),
2 => t('Wednesday'),
3 => t('Thursday'),
4 => t('Friday'),
5 => t('Saturday'),
6 => t('Sunday'),
),
或:
'#options' => drupal_map_assoc(
array(0,1,2,3,4,5,6)
),
...看起来像:
请从您当前的 $ multi_reg_checkbox
的电子邮件输出中发布您的屏幕答案 1 :(得分:1)
我知道这个问题很老......但是......你怎么称呼这个表格?你是从hook_menu做的吗?如果是这样的话:你确定要把
&#39;页面回调&#39; =&GT; &#39; drupal_get_form&#39 ;, &#39;页面参数&#39; =&GT;阵列(&#39; multi_reg_pagecreate&#39),