summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-05-22 14:51:15 +0200
committerYorhel <git@yorhel.nl>2009-05-22 14:51:15 +0200
commit55e67a4c4f690b14c06e2a6b2c6608e2305dceb6 (patch)
treed6891420ed30c8e3594e307d13005add9a895e92 /lib
parent6a5b24e04aadbb5a0327c4ce335f37f1506000a1 (diff)
<optgroup> support for the select input type in FormHTML
The third argument in the options item list is considered as the label for the optgroup the item is in.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Util/FormHTML.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index ed4443cc..111fa5a6 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -186,9 +186,17 @@ sub htmlFormPart {
lit ref $o{content} eq 'CODE' ? $o{content}->($self, \%o) : $o{content};
}
if(/select/) {
+ my $l='';
Select name => $o{short}, id => $o{short}, $o{width} ? (style => "width: $o{width}px") : ();
- option value => $_->[0], defined $frm->{$o{short}} && $frm->{$o{short}} eq $_->[0] ? (selected => 'selected') : (), $_->[1]
- for @{$o{options}};
+ for (@{$o{options}}) {
+ if($_->[2] && $l ne $_->[2]) {
+ end if $l;
+ $l = $_->[2];
+ optgroup label => $l;
+ }
+ option value => $_->[0], defined $frm->{$o{short}} && $frm->{$o{short}} eq $_->[0] ? (selected => 'selected') : (), $_->[1];
+ }
+ end if $l;
end;
}
if(/date/) {