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
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'.
Hope that helps.
-----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
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'.
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@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/ ]
You can add issues here - http://drupal.org/node/add/project-issue/drupal Also you can check on issues here - http://drupal.org/project/issues/drupal
On Fri, Jan 13, 2012 at 9:17 PM, Shawn Webb lattera@gmail.com wrote:
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@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/ ]
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@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Friday, January 13, 2012 7:48 AM To: support@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@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/ ]
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@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@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Friday, January 13, 2012 7:48 AM To: support@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@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/ ]
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@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Friday, January 13, 2012 8:23 AM To: support@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@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@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Friday, January 13, 2012 7:48 AM To: support@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@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/ ]
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@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@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Friday, January 13, 2012 8:23 AM To: support@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@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@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Friday, January 13, 2012 7:48 AM To: support@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@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/ ]
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
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/ ]
I think it's premature to file a bug. I verified the correct behavior in my drupal 7 innstance. #multiple does work correctly. I had initially looked at the wrong procedure, so I got misled by the return of a closely named procedure.
Change line 91 to read:
$servers[] = $record->servername;
Also you can add before the return
drupal_set_message(print_r($servers,1));
just as you return $servers so that you can verify that you're getting the data back correctly.
Finally I couldn't help but notice that gatt_all_servers_assoc is getting data $record->name, but at 91, you're pulling $record->servername. Is this in error?
Dave
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shawn Webb Sent: Thursday, January 12, 2012 3:05 PM To: support@drupal.org Subject: Re: [support] Setting Multiselect Default Values
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/ ]
So why doesn't it work when I even set it manually to any of the values I posted in the original email? Those values are the exact same as what you just said to do.
Sent from my Android device. please forgive any spelling or grammatical errors. On Jan 12, 2012 4:38 PM, "Metzler, David" metzlerd@evergreen.edu wrote:
I think it’s premature to file a bug. I verified the correct behavior in my drupal 7 innstance. #multiple does work correctly. I had initially looked at the wrong procedure, so I got misled by the return of a closely named procedure. ****
Change line 91 to read: ****
$servers[] = $record->servername; ****
Also you can add before the return ****
drupal_set_message(print_r($servers,1)); ****
just as you return $servers so that you can verify that you’re getting the data back correctly. ****
Finally I couldn’t help but notice that gatt_all_servers_assoc is getting data $record->name, but at 91, you’re pulling $record->servername. Is this in error? ****
Dave****
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of *Shawn Webb *Sent:* Thursday, January 12, 2012 3:05 PM *To:* support@drupal.org *Subject:* Re: [support] Setting Multiselect Default Values****
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/ ]****
-- [ Drupal support list | http://lists.drupal.org/ ]