7
我正在使用drupal form api并使用复选框。我在使用默认检查值时遇到问题。以下是代码片段...drupal form api复选框
$result = db_query("SELECT nid, filepath FROM {content_type_brand}, {files} WHERE content_type_brand.field_brand_image_fid
= files.fid");
$items = array();
while ($r = db_fetch_array($result)) {
array_push($items, $r);
}
$options = array();
foreach($items as $i) {
$imagePath = base_path().$i['filepath'];
$options[$i['nid']] = '<img src="'.$imagePath.'"></img>';
}
$form['favorite_brands'] = array (
'#type' => 'fieldset',
'#title' => t('Favorite Brands'),
//'#weight' => 5,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['favorite_brands']['brands_options']
= array(
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => $options_checked,// $options_checked is an array similar to $options but having elements which need to be checked by default...
'#multicolumn' => array('width' => 3)
);
但价值不被默认选中...谁能帮我缺少的是什么?
感谢
其中是$ options_checked定义? 问题是提供的代码片段没有以任何方式定义$ options_checked,因此默认情况下没有复选框被选中 – zerolab 2011-02-25 02:12:10