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