%doc>
Display a
containing multiple checkboxes
USAGE:
<& /elements/tr-checkbox-multipe.html,
label => emt('Label'),
field => 'field_name',
options => ['opt1', 'opt2'],
labels => {
opt1 => 'Option 1',
opt2 => 'Option 2',
},
value => {
opt2 => '1', # opt2 defaults as checked
}
&>
%doc>
<% include('tr-td-label.html', @_ ) %>
>
% foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
{$option} || $value eq $option
? ' CHECKED' : ''
%>
<% $onchange %>
> <% $labels->{$option} %>
% }
|
<%init>
my %opt = @_;
my $onchange = $opt{'onchange'}
? 'onChange="'. $opt{'onchange'}. '(this)"'
: '';
my $value = $opt{'curr_value'} || $opt{'value'};
$value = $opt{default_value} if $opt{default_value} && !defined($value);
my $labels = $opt{'option_labels'} || $opt{'labels'};
my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
%init>