adding export to read mailbox status information, RT#15987
[freeside.git] / httemplate / elements / select.html
1 % unless ( $opt{'js_only'} ) {
2
3 <SELECT NAME          = "<% $opt{field} %>"
4         ID            = "<% $opt{id} %>"
5         previousValue = "<% $curr_value %>"
6         previousText  = "<% $labels->{$curr_value} || $curr_value %>"
7         <% $style %>
8         <% $opt{disabled} %>
9         <% $onchange %>
10 >
11
12 % if ( $opt{options} ) {
13 %
14 %   foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
15
16       <OPTION VALUE="<% $option %>"
17               <% $opt{curr_value} eq $option ? 'SELECTED' : '' %>
18       >
19         <% $labels->{$option} || $option %>
20       </OPTION>
21
22 %   }
23 %
24 % } else { #deprecated weird value hashref used only by reason.html
25 %
26 %   my $aref = $opt{'value'}->{'values'};
27 %   my $vkey = $opt{'value'}->{'vcolumn'};
28 %   my $ckey = $opt{'value'}->{'ccolumn'};
29 %   foreach my $v (@$aref) {
30
31       <OPTION VALUE="<% $v->$vkey %>"
32               <% ($opt{curr_value} eq $v->$vkey) ? 'SELECTED' : '' %>
33       >
34         <% $v->$ckey %>
35       </OPTION>
36
37 %   }
38 %
39 % }
40
41 </SELECT>
42
43 % }
44 <%init>
45
46 my %opt = @_;
47
48 my $labels = $opt{'option_labels'} || $opt{'labels'};
49
50 my $curr_value = $opt{'curr_value'};
51
52 my $onchange = '';
53 if ( $opt{'onchange'} ) {
54   $onchange = $opt{'onchange'};
55   $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
56   $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
57                                         #callbacks should act the same
58   $onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i;
59 }
60
61 $opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
62   if ref($opt{'disabled'}) eq 'CODE';
63 $opt{'disabled'} = 'DISABLED'
64   if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
65
66 my @style = ref($opt{'style'})
67               ? @{ $opt{'style'} }
68               : $opt{'style'}
69                 ? ( $opt{'style'} )
70                 : ();
71
72 my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
73
74
75 </%init>