Line # Revision Author
1 3 ahitrov@rambler.ru %# vim:syn=mason
2 <select name="<% $name %>"<% $already_set && "style='background-color: $already_set'" %>onChange="javascript: this.style.backgroundColor = this.options[this.selectedIndex].value;"<% $prop->{multiple} && ' multiple' %><% $prop->{size} && ' size="'.$prop->{size}.'"' %>>
3 %
4 % if ($prop->{allow_null}) {
5 %
6 <option value="" <% defined $check ? '' : 'selected' %>>--- �� ������� ---</option>
7 %
8 % }
9 %
10 % for my $chain (@chains) {
11 %
12 % my $selected = defined $chain && ( ref $check eq 'ARRAY' ? grep { $_ eq $chain } @$check : $check eq $chain ? 1 : 0 );
13 % $found++ if $selected;
14 %
15 <option value="<% $chain %>" style="background-color: <% $chain %>"<% $selected && ' selected' %>><% $chain %></option>
16 %
17 % }
18 %
19 % #if used not allowed value
20 % if ( $check and not $found ) {
21 %
22 <option value="<% $check %>" selected style="color:red;"><% $check %></option>
23 %
24 % }
25 %
26 </select>
27 <%args>
28
29 $prop => undef
30 $name => undef
31 $values => []
32 $check => undef
33 $options => undef
34
35 </%args>
36 <%init>
37
38 my $found = 0;
39 my @chains = ();
40 my $already_set;
41
42 if ( ref $options && exists $options->{$name} ) {
43 @chains = @{ $options->{$name} };
44
45 ($already_set) = grep { defined } (ref $check eq 'ARRAY' ? @$check : $check);
46 }
47
48 </%init>
49