line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Element::Multi; |
2
|
|
|
|
|
|
|
|
3
|
51
|
|
|
51
|
|
14674
|
use strict; |
|
51
|
|
|
|
|
71
|
|
|
51
|
|
|
|
|
1987
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
51
|
|
|
51
|
|
195
|
use Moose; |
|
51
|
|
|
|
|
74
|
|
|
51
|
|
|
|
|
310
|
|
7
|
|
|
|
|
|
|
extends 'HTML::FormFu::Element::Block'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with |
10
|
|
|
|
|
|
|
'HTML::FormFu::Role::Element::Field', |
11
|
|
|
|
|
|
|
'HTML::FormFu::Role::Element::SingleValueField'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use HTML::FormFu::Util |
14
|
51
|
|
|
51
|
|
236820
|
qw( append_xml_attribute xml_escape process_attrs _parse_args _get_elements _filter_components ); |
|
51
|
|
|
|
|
75
|
|
|
51
|
|
|
|
|
3164
|
|
15
|
51
|
|
|
51
|
|
208
|
use Clone (); |
|
51
|
|
|
|
|
68
|
|
|
51
|
|
|
|
|
44911
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
after BUILD => sub { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$self->comment_attributes( {} ); |
21
|
|
|
|
|
|
|
$self->container_attributes( {} ); |
22
|
|
|
|
|
|
|
$self->label_attributes( {} ); |
23
|
|
|
|
|
|
|
$self->layout_field_filename('field_layout_multi_field'); |
24
|
|
|
|
|
|
|
$self->label_tag('label'); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_fields { |
30
|
596
|
|
|
596
|
|
1193
|
my $self = shift; |
31
|
596
|
|
|
|
|
1138
|
my %args = _parse_args(@_); |
32
|
|
|
|
|
|
|
|
33
|
596
|
|
|
|
|
1622
|
my $f = $self->SUPER::get_fields(@_); |
34
|
|
|
|
|
|
|
|
35
|
596
|
|
|
|
|
1160
|
unshift @$f, $self; |
36
|
|
|
|
|
|
|
|
37
|
596
|
|
|
|
|
1012
|
return _get_elements( \%args, $f ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_deflators { |
41
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
42
|
0
|
|
|
|
|
0
|
my %args = _parse_args(@_); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
my @x = @{ $self->_deflators }; |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
push @x, map { @{ $_->get_deflators(@_) } } @{ $self->_elements }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
return _filter_components( \%args, \@x ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_filters { |
52
|
12
|
|
|
12
|
|
21
|
my $self = shift; |
53
|
12
|
|
|
|
|
43
|
my %args = _parse_args(@_); |
54
|
|
|
|
|
|
|
|
55
|
12
|
|
|
|
|
27
|
my @x = @{ $self->_filters }; |
|
12
|
|
|
|
|
328
|
|
56
|
|
|
|
|
|
|
|
57
|
12
|
|
|
|
|
25
|
push @x, map { @{ $_->get_filters(@_) } } @{ $self->_elements }; |
|
28
|
|
|
|
|
24
|
|
|
28
|
|
|
|
|
80
|
|
|
12
|
|
|
|
|
290
|
|
58
|
|
|
|
|
|
|
|
59
|
12
|
|
|
|
|
37
|
return _filter_components( \%args, \@x ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_constraints { |
63
|
12
|
|
|
12
|
|
20
|
my $self = shift; |
64
|
12
|
|
|
|
|
38
|
my %args = _parse_args(@_); |
65
|
|
|
|
|
|
|
|
66
|
12
|
|
|
|
|
18
|
my @x = @{ $self->_constraints }; |
|
12
|
|
|
|
|
355
|
|
67
|
|
|
|
|
|
|
|
68
|
12
|
|
|
|
|
25
|
push @x, map { @{ $_->get_constraints(@_) } } @{ $self->_elements }; |
|
28
|
|
|
|
|
21
|
|
|
28
|
|
|
|
|
78
|
|
|
12
|
|
|
|
|
288
|
|
69
|
|
|
|
|
|
|
|
70
|
12
|
|
|
|
|
39
|
return _filter_components( \%args, \@x ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_inflators { |
74
|
11
|
|
|
11
|
|
22
|
my $self = shift; |
75
|
11
|
|
|
|
|
35
|
my %args = _parse_args(@_); |
76
|
|
|
|
|
|
|
|
77
|
11
|
|
|
|
|
18
|
my @x = @{ $self->_inflators }; |
|
11
|
|
|
|
|
327
|
|
78
|
|
|
|
|
|
|
|
79
|
11
|
|
|
|
|
17
|
push @x, map { @{ $_->get_inflators(@_) } } @{ $self->_elements }; |
|
26
|
|
|
|
|
26
|
|
|
26
|
|
|
|
|
70
|
|
|
11
|
|
|
|
|
264
|
|
80
|
|
|
|
|
|
|
|
81
|
11
|
|
|
|
|
35
|
return _filter_components( \%args, \@x ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub get_validators { |
85
|
11
|
|
|
11
|
|
17
|
my $self = shift; |
86
|
11
|
|
|
|
|
34
|
my %args = _parse_args(@_); |
87
|
|
|
|
|
|
|
|
88
|
11
|
|
|
|
|
17
|
my @x = @{ $self->_validators }; |
|
11
|
|
|
|
|
302
|
|
89
|
|
|
|
|
|
|
|
90
|
11
|
|
|
|
|
22
|
push @x, map { @{ $_->get_validators(@_) } } @{ $self->_elements }; |
|
26
|
|
|
|
|
20
|
|
|
26
|
|
|
|
|
72
|
|
|
11
|
|
|
|
|
255
|
|
91
|
|
|
|
|
|
|
|
92
|
11
|
|
|
|
|
32
|
return _filter_components( \%args, \@x ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_transformers { |
96
|
11
|
|
|
11
|
|
19
|
my $self = shift; |
97
|
11
|
|
|
|
|
31
|
my %args = _parse_args(@_); |
98
|
|
|
|
|
|
|
|
99
|
11
|
|
|
|
|
20
|
my @x = @{ $self->_transformers }; |
|
11
|
|
|
|
|
320
|
|
100
|
|
|
|
|
|
|
|
101
|
11
|
|
|
|
|
23
|
push @x, map { @{ $_->get_transformers(@_) } } @{ $self->_elements }; |
|
26
|
|
|
|
|
25
|
|
|
26
|
|
|
|
|
67
|
|
|
11
|
|
|
|
|
269
|
|
102
|
|
|
|
|
|
|
|
103
|
11
|
|
|
|
|
33
|
return _filter_components( \%args, \@x ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub get_errors { |
107
|
317
|
|
|
317
|
|
356
|
my $self = shift; |
108
|
317
|
|
|
|
|
700
|
my %args = _parse_args(@_); |
109
|
|
|
|
|
|
|
|
110
|
317
|
|
|
|
|
337
|
my @x = @{ $self->_errors }; |
|
317
|
|
|
|
|
8574
|
|
111
|
|
|
|
|
|
|
|
112
|
317
|
|
|
|
|
389
|
push @x, map { @{ $_->get_errors(@_) } } @{ $self->_elements }; |
|
907
|
|
|
|
|
692
|
|
|
907
|
|
|
|
|
1752
|
|
|
317
|
|
|
|
|
7373
|
|
113
|
|
|
|
|
|
|
|
114
|
317
|
|
|
|
|
643
|
_filter_components( \%args, \@x ); |
115
|
|
|
|
|
|
|
|
116
|
317
|
100
|
|
|
|
657
|
if ( !$args{forced} ) { |
117
|
230
|
|
|
|
|
240
|
@x = grep { !$_->forced } @x; |
|
28
|
|
|
|
|
701
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
317
|
|
|
|
|
799
|
return \@x; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub clear_errors { |
124
|
82
|
|
|
82
|
|
115
|
my ($self) = @_; |
125
|
|
|
|
|
|
|
|
126
|
82
|
|
|
|
|
2097
|
$self->_errors( [] ); |
127
|
|
|
|
|
|
|
|
128
|
82
|
|
|
|
|
96
|
map { $_->clear_errors } @{ $self->_elements }; |
|
135
|
|
|
|
|
379
|
|
|
82
|
|
|
|
|
2082
|
|
129
|
|
|
|
|
|
|
|
130
|
82
|
|
|
|
|
181
|
return; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub render_data { |
134
|
34
|
|
|
34
|
|
79
|
my $self = shift; |
135
|
|
|
|
|
|
|
|
136
|
34
|
|
|
|
|
173
|
my $render = $self->SUPER::render_data(@_); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
map { |
139
|
|
|
|
|
|
|
delete $_->{container_tag} |
140
|
34
|
50
|
|
|
|
46
|
} @{ $render->{elements} || [] }; |
|
66
|
|
|
|
|
107
|
|
|
34
|
|
|
|
|
127
|
|
141
|
|
|
|
|
|
|
|
142
|
34
|
|
|
|
|
84
|
return $render; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub render_data_non_recursive { |
146
|
|
|
|
|
|
|
my $self = shift; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $render = $self->SUPER::render_data_non_recursive(@_); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
append_xml_attribute( $render->{attributes}, 'class', 'elements' ); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
return $render; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub _parse_layout_field { |
156
|
73
|
|
|
73
|
|
100
|
my ( $self, $render ) = @_; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
my @html = ( |
159
|
73
|
|
|
|
|
249
|
sprintf "<span%s>", process_attrs( $render->{attributes} ), |
160
|
|
|
|
|
|
|
); |
161
|
|
|
|
|
|
|
|
162
|
73
|
|
|
|
|
148
|
for my $elem ( @{ $self->get_elements } ) { |
|
73
|
|
|
|
|
424
|
|
163
|
218
|
|
|
|
|
661
|
my $render = $elem->render_data; |
164
|
|
|
|
|
|
|
|
165
|
218
|
100
|
|
|
|
490
|
next if !defined $render; |
166
|
|
|
|
|
|
|
|
167
|
217
|
|
|
|
|
342
|
$render->{container_tag} = undef; |
168
|
|
|
|
|
|
|
|
169
|
217
|
|
|
|
|
775
|
push @html, $elem->string( { render_data => $render, layout => $elem->multi_layout } ); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
73
|
|
|
|
|
202
|
push @html, "</span>"; |
173
|
|
|
|
|
|
|
|
174
|
73
|
|
|
|
|
667
|
return join "\n", @html; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub clone { |
178
|
|
|
|
|
|
|
my $self = shift; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my $clone = $self->SUPER::clone(@_); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
$clone->comment_attributes( Clone::clone( $self->comment_attributes ) ); |
183
|
|
|
|
|
|
|
$clone->container_attributes( Clone::clone( $self->container_attributes ) ); |
184
|
|
|
|
|
|
|
$clone->label_attributes( Clone::clone( $self->label_attributes ) ); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
return $clone; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
__END__ |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 NAME |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
HTML::FormFu::Element::Multi - Combine multiple fields in a single element |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 VERSION |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
version 2.05 |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 SYNOPSIS |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
my $e = $form->element( Multi => 'foo' ); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 DESCRIPTION |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Combine multiple form fields in a single logical element. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Non-field elements cannot be added as children of the Multi element. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 RENDERING NOTES |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
If the Multi element is rendered with the default 'string' render-method, |
216
|
|
|
|
|
|
|
all child fields will be rendered with the 'string' render-method, regardless |
217
|
|
|
|
|
|
|
of their L<HTML::FormFu/render_method> value. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Likewise, if the Multi element is rendered with the 'tt' render-method, |
220
|
|
|
|
|
|
|
all child fields will be rendered with the 'tt' render-method, regardless of |
221
|
|
|
|
|
|
|
their L<HTML::FormFu/render_method> value. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 SEE ALSO |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Is a sub-class of, and inherits methods from |
226
|
|
|
|
|
|
|
L<HTML::FormFu::Role::Element::Field>, |
227
|
|
|
|
|
|
|
L<HTML::FormFu::Element> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L<HTML::FormFu> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 AUTHOR |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 LICENSE |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
238
|
|
|
|
|
|
|
the same terms as Perl itself. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=cut |