summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-table.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements/select-table.html')
-rw-r--r--httemplate/elements/select-table.html10
1 files changed, 9 insertions, 1 deletions
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 0c3c00563..3235ef627 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -9,8 +9,11 @@
<OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) {
+% my $matches = 0;
+% ref($opt{'value'}) ? (exists($opt{'value'}->{$record->$key()}) and $matches=1)
+% : ($opt{'value'} == $record->$key() and $matches=1);
- <OPTION VALUE="<% $record->$key() %>"<% $opt{'value'} == $record->$key() ? ' SELECTED' : '' %>><% $record->$name_col() %>
+ <OPTION VALUE="<% $record->$key() %>"<% $matches ? ' SELECTED' : '' %>><% $record->$name_col() %>
% }
@@ -59,6 +62,7 @@ if ( $opt{records} ) {
}
unless ( ! $opt{value}
+ or ref($opt{value})
or ! exists( $opt{hashref}->{disabled} ) #??
or grep { $opt{value} == $_->$key() } @records
) {
@@ -72,6 +76,10 @@ unless ( ! $opt{value}
push @records, $record if $record;
}
+if ( ref( $opt{value} ) eq 'ARRAY' ) {
+ $opt{value} = { map { $_ => 1 } @{$opt{value}} };
+}
+
my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : ();
</%init>