Answers:
请参阅以下示例...
$options = array();
$options["1"] = "One";
$options["2"] = "Two";
$options["3"] = "Three";
$options["4"] = "Four";
$form['ios'] = array(
'#title' => t(''),
'#type' => 'checkboxes',
'#description' => t(''),
'#options' => $options,
'#default_value' => array("1", "2", "3")
);
您具有“新闻信”或“条款条件”之类的“单一字段”复选框,可以使用以下代码
$form['name']['terms_condition'] = array(
'#type' =>'checkbox',
'#title'=>t('Terms and conditions'),
'#required'=>TRUE,
'#default_value' =>TRUE, // for default checked and false is not checked
);
你尝试了吗?
$form['ios'] = array(
'#title' => t(''),
'#type' => 'checkboxes',
'#description' => t(''),
'#options' => $options,
'#default_value' => array($value) // this is not working
);
//$value should be the option you want to have
奥斯卡
true
?