Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / elements / tr-checkbox-multiple.html
1 <%doc>
2
3 Display a <tr> containing multiple checkboxes
4
5 USAGE:
6
7 <& /elements/tr-checkbox-multipe.html,
8   label => emt('Label'),
9   field => 'field_name',
10   options => ['opt1', 'opt2'],
11   labels => {
12     opt1 => 'Option 1',
13     opt2 => 'Option 2',
14   },
15   value => {
16     opt2 => '1', # opt2 defaults as checked
17   }
18 &>
19
20 </%doc>
21 <% include('tr-td-label.html', @_ ) %>
22
23   <TD <% $style %>>
24
25 %   foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
26
27       <INPUT TYPE  = "checkbox"
28              NAME  = "<% $opt{field} %>"
29              ID    = "<% $opt{id}.'_'.$option %>"
30              VALUE = "<% $option %>"
31              <% ref($value) && $value->{$option} || $value eq $option
32                   ? ' CHECKED' : ''
33              %>
34              <% $onchange %>
35
36       >&nbsp;<% $labels->{$option} %>
37
38       <BR>
39
40 %   }
41
42   </TD>
43
44 </TR>
45
46 <%init>
47
48 my %opt = @_;
49
50 my $onchange = $opt{'onchange'}
51                  ? 'onChange="'. $opt{'onchange'}. '(this)"'
52                  : '';
53
54 my $value = $opt{'curr_value'} || $opt{'value'};
55
56 $value = $opt{default_value} if $opt{default_value} && !defined($value);
57
58 my $labels = $opt{'option_labels'} || $opt{'labels'};
59
60 my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
61
62 </%init>