formapi - drupal form api checkboxes -


i using drupal form api , using checkboxes. getting problem in default checked values it. following code snippet...

$result = db_query("select nid, filepath {content_type_brand}, {files} 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 $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 array similar $options having elements need checked default...             '#multicolumn' => array('width' => 3)         ); 

but values not checked default... can missing??

thanks

your $options_checked array should not in same format $options array. $options array contains nid => img tag pairs. $options_checked array should contain nid values of options should checked default:

$options_checked = array(8,17); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -