Line # Revision Author
1 8 ahitrov@rambler.ru % if ( $error ) {
2 <font color="red"><% $error %></font>
3 % } else {
4 % foreach my $id ( @values ) {
5 % if ( ref $id eq 'ARRAY' && scalar @$id == 2 ) {
6 % my $checked = exists $ids{$id->[0]} ? ' checked' : '';
7 <input <% $prop->{readonly} ? 'readonly ' : '' %>type="checkbox" name="<% $name %>_<% $id->[0] %>" value="<% $value %>" <% $checked %>><% $id->[1] %><br>
8 % } else {
9 % my $checked = exists $ids{$id} ? ' checked' : '';
10 <input <% $prop->{readonly} ? 'readonly ' : '' %>type="checkbox" name="<% $name %>_<% $id %>" value="<% $value %>" <% $checked %>><% $id %><br>
11 % }
12 % }
13 % }
14 <%args>
15
16 $object
17 $name => undef
18 $value => 1
19 $check => undef
20 $prop => {}
21
22 </%args>
23 <%init>
24
25 my ($objects, $error);
26
27 # ���� ��� �������� � ���� ���� integer[] �� ��� �������� ������, ���� � data, �� ������ �� ������.
28 # ��������� �����
29 my @ids = ref($object->$name) eq 'ARRAY' ? @{ $object->$name } : $object->$name;
30 my %ids = map { $_ => 1 } @ids;
31 my @values = exists $prop->{values} && ref $prop->{values} eq 'ARRAY' ? @{ $prop->{values} } :
32 exists $prop->{cases} && ref $prop->{cases} eq 'ARRAY' ? @{ $prop->{cases} } : ();
33
34 $error = '�� ��������� ����� �������� ��� ����' unless @values;
35
36 </%init>