[support] Setting Multiselect Default Values

Metzler, David metzlerd at evergreen.edu
Fri Jan 13 16:14:12 UTC 2012


Nancy's point about functionality removed in D7 was about allowing
direct use of db_query, not about #multiple support, which you pointed
out correctly in your last response is NOT what you are doing.  

#multiple and #default_value DOES work.   I really do believe that
you're just not getting back the data you think you are. I'm pretty sure
I've got your bug identified, but I'm not sure you caught it.
($record->servername should be $record->name). 

Would you consider adding the drupal_set_message I requested to verify
that you are getting back the array you think you are? If not, try out
the following code which works on my site.  Before you file a bug you
need to have a SIMPLE stub to demonstrate the flaw. 

function test_menu() {
    $items['t'] = array(
     'type' => MENU_NORMAL_ITEM,
     'title' => 'Test Page',
     'page callback' => 'test_page',
     'access callback' => true,
     );

  return $items;
}


function test_page($parm1='',$parm2='') {
  $output .= drupal_render(drupal_get_form('test_form'));
  return $output;
}

function test_form($form, &$form_state) {

  $form['servers'] = array('#type' => 'select',
    '#title' => 'Servers',
    '#multiple' => true,
    '#options' => array('SERVER01'=>'SERVER01', 'SERVER02' =>
'SERVER02'),
    '#default_value' => array('SERVER01', 'SERVER02'),
    );
  $form['submit'] = array('#type' => 'submit', '#value' => 'Submit');
  return $form;
}


-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Shawn Webb
Sent: Friday, January 13, 2012 7:48 AM
To: support at drupal.org; Ms. Nancy Wichmann
Subject: Re: [support] Setting Multiselect Default Values

So it sounds like the functionality was in Drupal 6 but removed in
Drupal 7. I probably ought to file a bug report (or feature request),
then, correct? I've figured out a workaround I can do, even though
it'd be completely ugly UI-wise.

How do I go about filing a bug report?

Thanks,

Shawn

On Thu, Jan 12, 2012 at 11:07 PM, Ms. Nancy Wichmann
<nan_wich at bellsouth.net> wrote:
> Actually, on D6, you can. I had a patch in D7, but it got removed by
DBTNG.
>
> Nancy
>
> Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L.
King,
> Jr.
>
> ________________________________
> From: "Metzler, David"Setting
>
> '#default_value' => array('SERVER01','SERVER02')
>
> Is the correct form.
>
> You cannot as you have done pass the results of a DB_QUERY directly to
> the '#default_value'.
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
-- 
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list