[html-formfu] option attributes

Dermot paikkos at googlemail.com
Wed Feb 4 14:49:22 GMT 2009


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.



my @options;
foreach (@Obj) {
        push(@options, {value => $_->id, label => $_->name,
attributes => {selected => 'selected'} } );
}
my $sel = $form->get_field({name => 'myselect'});
$sel->options(\@options);


conf:
  - type: Select
    name: myselect
    label: Test
    attributes:
      title: The options
      size: 7
      class: selection list


...renders:
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
...
<option value="1" selected="selected">opt1</option>
<option value="2" selected="selected">opt2</option>
<option value="3" selected="selected">opt3</option>
<option value="4" selected="selected">opt4</option>


I am trying to highlight them all in this case.
Thanx,
Dp.



More information about the HTML-FormFu mailing list