On 4/30/2010 2:58 PM, Randy Fay wrote:
First, use an associative array for your options list, which as you've
already discovered is completely wrong in the code you sent out.
'#options' => array("orange" => t("orange"),... ) or '#options' =>
array('or' => t('Orange'))... or '#options' => array('1' =>
t('Orange'), ...)
Second, use only strings for the keys of the associative array (I've
seen numeric keys cause some difficulty here in D7 at least)
You don't mention what version of Drupal you're working with.
Sorry. It's D6. Ok, made sure of all that, so now in the form field
part, I have:
$form['myform']['mytypes'][$key] = array(
'#type' => 'select',
'#title' => t($key),
'#options' => $results_tabs,
'#default_value' => $results_tabs[$val]
);
$results_tabs is an associative array, now defined as $results_tabs =>
array(''=>'none','a'=>'a','b'=>'b');
$key='a'
$val='a'
When I dpm $forms at the end, it shows, for example,
#default_value=>'a'
and options contains the key/value pairs from $results_tabs, yet the
dropdown when the page paints is 'none'