I understand. However, I'm not setting the default value directly from db_query. I'm setting it as you suggested, but I'm not seeing the correct result. That is the issue. Even though I'm setting it as everyone has suggested, I'm still not seeing them selected by default.

I also understand that I should run the submitted values through array_filter.  That's not the issue.

Let me know if or how I should file a bug report.

Thanks,

Shawn

Sent from my Android device. please forgive any spelling or grammatical errors.

On Jan 12, 2012 3:48 PM, "Metzler, David" <metzlerd@evergreen.edu> wrote:
PS.

IT's important to know that what you get back in your submit handler for
$formstate['values']['new_server']is an array of all of the servers and
wheter they are selected.  In the case where SERVER01 and SERVER02 are
selected you'll get back the array:

Array(
 'SERVER01' => 'SERVER01',
 'SERVER02' => 'SERVER02',
 'SERVER03' => 0,
 'SERVER04' => 0,
 'SERVER05' => 0
);

You will not get back string data as your code seems to be expecting.

Dave



-----Original Message-----
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On
Behalf Of Shawn Webb
Sent: Thursday, January 12, 2012 2:18 PM
To: support@drupal.org
Subject: [support] Setting Multiselect Default Values

Hey Fellow Drupalers,

I'm trying to set the '#default_value' property to a select form
element that has '#multiple' set to TRUE. Below you will find a link
to the source and a link to a screenshot. I've tried setting
'#default_value' to:

[values]
array('SERVER01')
array('SERVER01' => 'SERVER01')
array(1)
array('1')
1
'SERVER01'
[/values]

But nothing sets the default value of the select form element. The
'#options' element is set to (verbatim from var_export): array (
'SERVER01' => 'SERVER01', 'SERVER02' => 'SERVER02', 'SERVER03' =>
'SERVER03', 'SERVER04' => 'SERVER04', 'SERVER05' => 'SERVER05', )

Links:
Screenshot: http://t.co/vVAcT4fA
Code: https://t.co/ETl4MtgV

The code in question is line 105 of vulnscan.admin.inc

Let me know what I should do. I'm running drupal 7.11-dev (git
checkout of Drupal codebase, set to the 7.x branch).

Thanks,

Shawn
--
[ Drupal support list | http://lists.drupal.org/ ]
--
[ Drupal support list | http://lists.drupal.org/ ]