'agent_null_right' => '', #right to see un-agented entries
#or
'records' => \@records, #instead of search params
+ 'presorted' => 0, #set true to disable sorting the records on name_col
#instead of the primary key... only for special cases
'value_col' => 'columnname',
#<SELECT> element
'onchange' => '', #javascript code
- #params (well, a param) controlling the <OPTION>s
+ #params controlling the <OPTION>s
'extra_option_attributes' => [ 'field' ], #field or method in $table objects
#(are prefixed w/data- per HTML5)
+ 'hidden_sub' => sub { my $rec = shift; $rec->disabled; }, #sets option hidden att if true
+ #won't hide selected options
+ #hidden att not supported IE < 11
#special return options
'js_only' => 0, #set true to return only the JS portions (i.e. nothing)
<OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
% }
-% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col()
-% || $a->$key() <=> $b->$key()
-% }
-% @records
+% foreach my $record (
+% # we have the order_by parameter for this
+% #sort { $a->$name_col() cmp $b->$name_col()
+% # || $a->$key() <=> $b->$key()
+% # }
+% @records
% )
% {
% my $recvalue = $record->$key();
% $selected = ( ref($value) && $value->{$recvalue} )
% || ( $value && $value eq $recvalue ); #not == because of value_col
% }
+% $opt{'hidden_sub'} ||= sub { 0 };
<OPTION VALUE="<% $recvalue %>"
<% $selected ? ' SELECTED' : '' %>
+ <% (&{$opt{'hidden_sub'}}($record) && !$selected) ? ' hidden' : '' %>
% foreach my $att ( @{ $opt{'extra_option_attributes'} } ) {
data-<% $att %>="<% $record->$att() |h %>"
% }
my @records = ();
if ( $opt{'records'} ) {
@records = @{ $opt{'records'} };
+ @records = sort { $a->get($name_col) cmp $b->get($name_col) } @records
+ unless $opt{'presorted'};
} else {
@records = qsearch( {
'table' => $opt{'table'},