summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-table.html
diff options
context:
space:
mode:
authorcvs2git <cvs2git>2009-10-11 02:42:17 +0000
committercvs2git <cvs2git>2009-10-11 02:42:17 +0000
commita83a000a027d1272e813259d09230d701d84df64 (patch)
tree71500c957e6d7db3e1ad3d59e74ca7bbb14e44ff /httemplate/elements/select-table.html
parent097a12385d80ef52f37d4cc2bb93bc3f81e6f8e6 (diff)
parent0b69c091543b56a45f2ae6b8718fc67f381a6686 (diff)
This commit was manufactured by cvs2svn to create branchfreeside_1_9_1
'FREESIDE_1_9_BRANCH'.
Diffstat (limited to 'httemplate/elements/select-table.html')
-rw-r--r--httemplate/elements/select-table.html22
1 files changed, 17 insertions, 5 deletions
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 4efbcba..10a8b27 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -34,6 +34,7 @@ Example:
'empty_label' => '', #better specify it though, the default might change
'multiple' => 0, # bool
'disable_empty' => 0, # bool (implied by multiple)
+ 'label_showkey' => 0, # bool
'label_callback' => sub { my $record = shift; return "label"; },
#more params controlling HTML stuff about the <SELECT>
@@ -64,21 +65,32 @@ Example:
>
% while ( @pre_options ) {
- <OPTION VALUE="<% shift(@pre_options) %>"><% shift(@pre_options) %>
-
+% my $pre_opt = shift(@pre_options);
+% my $pre_label = shift(@pre_options);
+% my $selected = ( ref($value) && $value->{$pre_opt} )
+% || ( $value eq $pre_opt );
+ <OPTION VALUE="<% $pre_opt %>"
+ <% $selected ? 'SELECTED' : '' %>
+ ><% $pre_label %>
% }
% unless ( $opt{'multiple'} || $opt{'disable_empty'} ) {
<OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
% }
-% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) {
+% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col()
+% || $a->$key() <=> $b->$key()
+% }
+% @records
+% )
+% {
% my $recvalue = $record->$key();
<OPTION VALUE="<% $recvalue %>"
<% ref($value) && $value->{$recvalue} || $value == $recvalue
? ' SELECTED' : ''
%>
- ><% $opt{'label_callback'}
+ ><% $opt{'label_showkey'} ? "$recvalue: " : '' %>
+ <% $opt{'label_callback'}
? &{ $opt{'label_callback'} }( $record )
: $record->$name_col()
%>
@@ -139,7 +151,7 @@ if ( $opt{'records'} ) {
});
}
-unless ( ! $value
+unless ( $value < 1 # !$value #ignore negatives too
or ref($value)
or ! exists( $opt{hashref}->{disabled} ) #??
or grep { $value == $_->$key() } @records