[html-formfu] option attributes
Dermot
paikkos at googlemail.com
Wed Feb 4 15:15:29 GMT 2009
2009/2/4 Carl Franks <fireartist at gmail.com>:
> 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
understood.
> and give default() an arrayref of values.
> $field->default([ 1, 2, 3, 4 ]);
Thanx that's worked.
Am I mistaken or is the rendered XHTML the same?
<option value="1" selected="selected"..
Thanx again,
Dp.
More information about the HTML-FormFu
mailing list