[support] Setting Multiselect Default Values
Metzler, David
metzlerd at evergreen.edu
Thu Jan 12 22:48:04 UTC 2012
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 at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Shawn Webb
Sent: Thursday, January 12, 2012 2:18 PM
To: support at 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/ ]
More information about the support
mailing list