blob: baf18f916e909b39c9957b2f2446aee34a6350a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<%doc>
Display a <tr> 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', @_ ) %>
<TD <% $style %>>
% foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
<INPUT TYPE = "checkbox"
NAME = "<% $opt{field} %>"
ID = "<% $opt{id}.'_'.$option %>"
VALUE = "<% $option %>"
<% ref($value) && $value->{$option} || $value eq $option
? ' CHECKED' : ''
%>
<% $onchange %>
> <% $labels->{$option} %>
<BR>
% }
</TD>
</TR>
<%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>
|