<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I have noticed with the default values
that you need to leave the form page and return to get it to load the new
default values. A refresh of the screen won’t work. I believe it is how
the Forms API functions, only looking for the default values for the initial
form display, and any reload after that it is looking for values from a
previous POST.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Greg<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> support-bounces@drupal.org
[mailto:support-bounces@drupal.org] <b><span style='font-weight:bold'>On Behalf
Of </span></b>Sarah.Vardy@student.griffith.edu.au<br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, November 27, 2007
9:26 PM<br>
<b><span style='font-weight:bold'>To:</span></b> support@drupal.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [support] [Fwd: Re:
How to add "selected" attribute to select list <option>tag]</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Hi Steve,<o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I just tested the code in firefox and it works. Maybe it is a browser
compliancy issue? <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Two of the names are displayed as selected initially.<o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Sarah<br>
----- Original Message -----<br>
From: Steve Edwards <killshot91@comcast.net><br>
Date: Wednesday, November 28, 2007 3:19 pm<br>
Subject: [support] [Fwd: Re: How to add "selected" attribute to
select list <option>tag]<br>
To: support@drupal.org<br>
<br>
> I guess I spoke too soon. I did it as an array<br>
> <br>
> #default_value => array(2,3)<br>
> <br>
> and upon viewing the source, I discovered that it adds the <br>
> selected="selected" attribute to my option tags like I <br>
> want. The <br>
> problem is, the items aren't being highlighted on the screen.<br>
> <br>
> so this code:<br>
> <br>
> *<br>
> * Define the project permissions settings form<br>
> */<br>
> function project_permissions_form($project_nid, $project_name) {<br>
> $form['#base'] = 'project_permissions_form';<br>
> <br>
> $form[$project_nid] = array(<br>
> '#type' => 'fieldset',<br>
> '#title' => $project_name,<br>
> '#collapsible' => TRUE,<br>
> '#collapsed' => FALSE,<br>
> );<br>
> <br>
> $form[$project_nid]['projects'] = array(<br>
> '#type' => 'textfield',<br>
> '#title' => t('Project name'),<br>
> '#maxlength' => 30,<br>
> '#size' => 30,<br>
> '#default_value' => $project_name,<br>
> );<br>
> <br>
> $form[$project_nid]['users'] = array(<br>
> '#type' => 'select',<br>
> '#title' => t('Users with access to <br>
> project'), '#description' => t('Select <br>
> users to be asssigned to the project'),<br>
> '#options' => _get_user_list(),<br>
> '#multiple' => TRUE,<br>
> '#default_value' => array(2,3),<br>
> );<br>
> <br>
> $form[$project_nid]['nid'] = array(<br>
> '#type' => 'hidden',<br>
> '#value'=> $project_nid,<br>
> );<br>
> <br>
> $form[$project_nid]['submit'] = array(<br>
> '#type' => 'submit',<br>
> '#value' => 'Submit'<br>
> );<br>
> return $form;<br>
> }<br>
> <br>
> <br>
> gives me this HTML:<br>
> <br>
> <div class="form-item"><br>
> <label for="edit-users">Users with access to
project: <br>
> </label> <select name="users[]" <br>
> multiple="multiple" class="form-select" id="edit-users"
<br>
> ><option value="1">admin</option><option <br>
> value="2"
selected="selected">bwald</option><option <br>
> value="3"
selected="selected">testuser</option><option <br>
> value="4">Brian</option><option <br>
> value="5">NickH</option></select><br>
> <div class="description">Select users to be
asssigned <br>
> to the project</div><br>
> </div><br>
> <br>
> So why wouldn't the items be highlighted on the screen?<br>
> <br>
> Steve<br>
> <br>
> -------- Original Message --------<br>
> Subject: Re: [support] How to add "selected" attribute to select
<br>
> list <option>tagDate: Tue, 27 Nov 2007 21:04:32 -0800<br>
> From: Steve Edwards <killshot91@comcast.net><br>
> To: support@drupal.org<br>
> References: <474CED98.8090201@comcast.net> <br>
> <AF8E53B658278947AA3E09E48EF4EDAC3D73A3@TRV1DMC00.TRV.local><br>
> Hmmm, getting closer, but I can't seem to get it to work. <br>
> No matter what I try, I can't get it to select anything.<br>
> <br>
> Here is what my select list looks like (in HTML)<br>
> <br>
> <option value="1">Name 1<br>
> <option value="2">Name 2<br>
> <option value="3">Name 3<br>
> <option value="4">Name 4<br>
> <option value="5">Name 5<br>
> <br>
> The value is the user's uid. number That being the case, what <br>
> would i use for #default_value? I've tried things like<br>
> <br>
> '#default_value' => array(1 => 'Name 1')<br>
> '#default_value' => 1<br>
> '#default_value' => 'Name 1'<br>
> <br>
> but I can't get any of them to work. Any ideas?<br>
> <br>
> Thanks.<br>
> <br>
> Steve<br>
> <br>
> <br>
> Greg Holsclaw wrote:<br>
> > Make the #default_value an array of the keys of the options <br>
> you want<br>
> > selected.<br>
> > <br>
> > $form['item'] = array(<br>
> > '#type' => 'select',<br>
> > ...<br>
> > '#options' => array of all options,<br>
> > '#default_value' => array of keys from above options.<br>
> > ...<br>
> > );<br>
> > <br>
> > Check<br>
> > <br>
>
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html>
/5#default_value for more info.<br>
> > <br>
> > Greg<br>
> > <br>
> > <br>
> > -----Original Message-----<br>
> > From: support-bounces@drupal.org [mailto:support-<br>
> bounces@drupal.org] On<br>
> > Behalf Of Steve Edwards<br>
> > Sent: Tuesday, November 27, 2007 8:25 PM<br>
> > To: support@drupal.org<br>
> > Subject: [support] How to add "selected" attribute to
select list<br>
> > <option>tag<br>
> > <br>
> > Well, I'm back again, and this time I have a question about <br>
> attributes> for select options in a form. I have a form <br>
> that has a <br>
> > select element (multi-select) that lists users. The form <br>
> is for some<br>
> > admin settings for a module. When the form is displayed, <br>
> I <br>
> > need to be able to highlight specific options in the list <br>
> based on data<br>
> > returned from a query. I've been looking all day, and <br>
> > haven't been able to figure it out. There is the <br>
> #attribute key, but it<br>
> > is for the field as whole (at least as far as I can <br>
> > determine), and doesn't work for each individual <option> tag.<br>
> > <br>
> > If anybody could point me in the right direction, I would <br>
> appreciate it.<br>
> > <br>
> > Thanks.<br>
> > <br>
> > Steve<br>
> <br>
> -- <br>
> [ Drupal support list | http://lists.drupal.org/ ]<br>
> <o:p></o:p></span></font></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br>
Research Computing Services <br>
Sarah.Vardy@student.griffith.edu.au <br>
0402241794</BR></BR> <o:p></o:p></span></font></p>
</div>
</body>
</html>