I am using drupal api form and using checkboxes. I am having problems with the default values checked. Below is a snippet of code ...
$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) );
but the default values are not checked ... can anyone help with what I am missing?
thanks
Tausif khan
source share