[development] Array of fields on an admin settings form

Jeff Greenberg jeff at ayendesigns.com
Fri Apr 30 22:04:52 UTC 2010

The example you sent back is correct, though it wouldn't prove itself 
with $default = '' ... the problem was that the text for default=null 
was the only value that -did- show. $default would need to be set = to 
one of the other values to prove out otherwise. That said, it does, and 
was indeed the browser <large sigh and chuckle>.  Thanks, Randy.


On 4/30/2010 5:20 PM, Randy Fay wrote:
> I find no problems with this code...
> function form_default_some_form() {
>   $default = '';
>   $options = array('' => 'none', 'a' => 'a', 'b' => 'b');
>   $form['myform']['mytypes'][$key] = array(
>    '#type' => 'select',
>    '#title' => 'Example select',
>    '#options' => $options,
>    '#default_value' => $default,
>   );
>   return $form;
> }
> It performs as expected on D6.16. I thought that the use of an empty 
> string for a key was screwy, but it doesn't seem to affect anything. 
> (But remember, that empty($string) will return TRUE where the string 
> has nothing in it, thus affecting lots of code you might not want to 
> affect.)
> Be careful that you don't have your browser tricking you by 
> autofilling the form. Ctrl-refresh or Shift-refresh or clear the 
> cache. Try another browser.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100430/6e1cfeed/attachment.html 

More information about the development mailing list