[development] Array of fields on an admin settings form
Randy Fay
randy at randyfay.com
Fri Apr 30 18:58:20 UTC 2010
First, use an associative array for your options list, which as you've
already discovered is completely wrong in the code you sent out.
'#options' => array("orange" => t("orange"),... ) or '#options' =>
array('or' => t('Orange'))... or '#options' => array('1' => t('Orange'),
...)
Second, use only strings for the keys of the associative array (I've seen
numeric keys cause some difficulty here in D7 at least)
You don't mention what version of Drupal you're working with.
-Randy
On Fri, Apr 30, 2010 at 12:28 PM, Jeff Greenberg <jeff at ayendesigns.com>wrote:
> Ignore the code in the first message. I've boiled down the problem to this:
> If the array of values I'm populating my select with is
> $myarray('apple','orange') and a select box should have 'orange' selected
> when I paint the form, '#default_value' => 'orange' or '#default_value' =>
> 1, neither cause the value showing in the select to be other than the
> no-selection value.
>
>
> On 4/30/2010 12:57 PM, Jeff Greenberg wrote:
>
>> Hi. I have an admin settings form that contains an array of select fields.
>> The problem is that when submitted, the values don't end up in the db and
>> are the select fields go back to having no selected value. The form was
>> working fine as checkboxes, but when the need arose for each label value to
>> have multiple values to choose from (instead of on/off) and I made it an
>> array of fields, as below, it stopped working.
>>
>
>
--
Randy Fay
Drupal Module and Site Development
randy at randyfay.com
+1 970.462.7450
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100430/c4dd1c83/attachment.html
More information about the development
mailing list