[html-formfu] option attributes

Carl Franks fireartist at gmail.com
Wed Feb 4 14:57:12 GMT 2009


2009/2/4 Dermot <paikkos at googlemail.com>:
> Hi,
>
> Is it possible to set the 'selected' attribute on a option element?
> I have tried selected => 1 and selected => 'selected' but nether give
> me the effect.

Like any other field, you just need to call:
    $field->default( $value )

where $value == the selected option's value, not it's label.

To select multiple options, you need to set $field->multiple(1)

    type: Select
    name: foo
    multiple: 1

and give default() an arrayref of values.
    $field->default([ 1, 2, 3, 4 ]);

Carl



More information about the HTML-FormFu mailing list