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