[support] Setting Multiselect Default Values

Shawn Webb lattera at gmail.com
Fri Jan 13 16:32:33 UTC 2012


I haven't really given up. I just need to move on to other things.
I'll probably take another look at it in my spare time. It could be
that my Drupal installation is messed up from the horribly crappy
examples given in the Pro Drupal 7 Development book. The code in that
book had errors in nearly every single code sample, so it's likely
that it could borked my Drupal install. I might be seeing bugs because
of that.

Thanks,

Shawn

On Fri, Jan 13, 2012 at 9:28 AM, Metzler, David <metzlerd at evergreen.edu> wrote:
> Trying to help here, but it sounds like you've given up.   I gave you stub code that I've run on Drupal 7 and DOES populate default values.  If/When you file a drupal core bug, expect the same scrutiny only more so.  Those are really busy people that monitor that queue.
>
> Wish you the best of luck.
>
> Dave
>
> -----Original Message-----
> From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of Shawn Webb
> Sent: Friday, January 13, 2012 8:23 AM
> To: support at drupal.org
> Subject: Re: [support] Setting Multiselect Default Values
>
> Here's my schema, and you'll see that the data I'm getting back is
> correct: https://gist.github.com/1607294
>
> I've tried manually setting to array('SERVER01', 'SERVER02', ...), and
> that does _not_ work. I've tried manually setting to array('SERVER01'
> => 'SERVER01', 'SERVER02' => 'SERVER02',  ...) and that does _not_
> work. I've tried manually setting to array(1) and that does _not_
> work. I've tried manually setting to array('1') and that does _not_
> work. I've tried setting to 'SERVER01' and that does _not_ work.
>
> I think we're going in circles here. I've manually tried every single
> thing to no avail. But it's okay, I've already coded the workaround,
> even if it is ugly on the eyes.
>
> Thanks,
>
> Shawn
>
> On Fri, Jan 13, 2012 at 9:14 AM, Metzler, David <metzlerd at evergreen.edu> wrote:
>> 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/ ]
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
> --
> [ Drupal support list | http://lists.drupal.org/ ]
> --
> [ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list