line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
51
|
|
|
51
|
|
18299
|
use strict; |
|
51
|
|
|
|
|
128
|
|
|
51
|
|
|
|
|
2820
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::FormFu::Element::Multi; |
4
|
|
|
|
|
|
|
$HTML::FormFu::Element::Multi::VERSION = '2.07'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Combine multiple fields in a single element |
6
|
|
|
|
|
|
|
|
7
|
51
|
|
|
51
|
|
467
|
use Moose; |
|
51
|
|
|
|
|
113
|
|
|
51
|
|
|
|
|
382
|
|
8
|
51
|
|
|
51
|
|
371285
|
use MooseX::Attribute::Chained; |
|
51
|
|
|
|
|
134
|
|
|
51
|
|
|
|
|
2996
|
|
9
|
|
|
|
|
|
|
extends 'HTML::FormFu::Element::Block'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with |
12
|
|
|
|
|
|
|
'HTML::FormFu::Role::Element::Field', |
13
|
|
|
|
|
|
|
'HTML::FormFu::Role::Element::SingleValueField'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use HTML::FormFu::Util |
16
|
51
|
|
|
51
|
|
612
|
qw( append_xml_attribute xml_escape process_attrs _parse_args _get_elements _filter_components ); |
|
51
|
|
|
|
|
289
|
|
|
51
|
|
|
|
|
4577
|
|
17
|
51
|
|
|
51
|
|
414
|
use Clone (); |
|
51
|
|
|
|
|
119
|
|
|
51
|
|
|
|
|
61958
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
after BUILD => sub { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$self->comment_attributes( {} ); |
23
|
|
|
|
|
|
|
$self->container_attributes( {} ); |
24
|
|
|
|
|
|
|
$self->label_attributes( {} ); |
25
|
|
|
|
|
|
|
$self->layout_field_filename('field_layout_multi_field'); |
26
|
|
|
|
|
|
|
$self->label_tag('label'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return; |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_fields { |
32
|
596
|
|
|
596
|
|
1047
|
my $self = shift; |
33
|
596
|
|
|
|
|
1529
|
my %args = _parse_args(@_); |
34
|
|
|
|
|
|
|
|
35
|
596
|
|
|
|
|
2385
|
my $f = $self->SUPER::get_fields(@_); |
36
|
|
|
|
|
|
|
|
37
|
596
|
|
|
|
|
1911
|
unshift @$f, $self; |
38
|
|
|
|
|
|
|
|
39
|
596
|
|
|
|
|
1540
|
return _get_elements( \%args, $f ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_deflators { |
43
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
44
|
0
|
|
|
|
|
0
|
my %args = _parse_args(@_); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
my @x = @{ $self->_deflators }; |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
push @x, map { @{ $_->get_deflators(@_) } } @{ $self->_elements }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
return _filter_components( \%args, \@x ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_filters { |
54
|
12
|
|
|
12
|
|
41
|
my $self = shift; |
55
|
12
|
|
|
|
|
60
|
my %args = _parse_args(@_); |
56
|
|
|
|
|
|
|
|
57
|
12
|
|
|
|
|
47
|
my @x = @{ $self->_filters }; |
|
12
|
|
|
|
|
483
|
|
58
|
|
|
|
|
|
|
|
59
|
12
|
|
|
|
|
30
|
push @x, map { @{ $_->get_filters(@_) } } @{ $self->_elements }; |
|
28
|
|
|
|
|
48
|
|
|
28
|
|
|
|
|
114
|
|
|
12
|
|
|
|
|
369
|
|
60
|
|
|
|
|
|
|
|
61
|
12
|
|
|
|
|
49
|
return _filter_components( \%args, \@x ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_constraints { |
65
|
12
|
|
|
12
|
|
29
|
my $self = shift; |
66
|
12
|
|
|
|
|
69
|
my %args = _parse_args(@_); |
67
|
|
|
|
|
|
|
|
68
|
12
|
|
|
|
|
40
|
my @x = @{ $self->_constraints }; |
|
12
|
|
|
|
|
411
|
|
69
|
|
|
|
|
|
|
|
70
|
12
|
|
|
|
|
33
|
push @x, map { @{ $_->get_constraints(@_) } } @{ $self->_elements }; |
|
28
|
|
|
|
|
49
|
|
|
28
|
|
|
|
|
95
|
|
|
12
|
|
|
|
|
359
|
|
71
|
|
|
|
|
|
|
|
72
|
12
|
|
|
|
|
55
|
return _filter_components( \%args, \@x ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_inflators { |
76
|
11
|
|
|
11
|
|
33
|
my $self = shift; |
77
|
11
|
|
|
|
|
44
|
my %args = _parse_args(@_); |
78
|
|
|
|
|
|
|
|
79
|
11
|
|
|
|
|
28
|
my @x = @{ $self->_inflators }; |
|
11
|
|
|
|
|
389
|
|
80
|
|
|
|
|
|
|
|
81
|
11
|
|
|
|
|
29
|
push @x, map { @{ $_->get_inflators(@_) } } @{ $self->_elements }; |
|
26
|
|
|
|
|
45
|
|
|
26
|
|
|
|
|
95
|
|
|
11
|
|
|
|
|
307
|
|
82
|
|
|
|
|
|
|
|
83
|
11
|
|
|
|
|
43
|
return _filter_components( \%args, \@x ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_validators { |
87
|
11
|
|
|
11
|
|
26
|
my $self = shift; |
88
|
11
|
|
|
|
|
45
|
my %args = _parse_args(@_); |
89
|
|
|
|
|
|
|
|
90
|
11
|
|
|
|
|
25
|
my @x = @{ $self->_validators }; |
|
11
|
|
|
|
|
367
|
|
91
|
|
|
|
|
|
|
|
92
|
11
|
|
|
|
|
31
|
push @x, map { @{ $_->get_validators(@_) } } @{ $self->_elements }; |
|
26
|
|
|
|
|
48
|
|
|
26
|
|
|
|
|
95
|
|
|
11
|
|
|
|
|
342
|
|
93
|
|
|
|
|
|
|
|
94
|
11
|
|
|
|
|
46
|
return _filter_components( \%args, \@x ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub get_transformers { |
98
|
11
|
|
|
11
|
|
26
|
my $self = shift; |
99
|
11
|
|
|
|
|
47
|
my %args = _parse_args(@_); |
100
|
|
|
|
|
|
|
|
101
|
11
|
|
|
|
|
36
|
my @x = @{ $self->_transformers }; |
|
11
|
|
|
|
|
372
|
|
102
|
|
|
|
|
|
|
|
103
|
11
|
|
|
|
|
33
|
push @x, map { @{ $_->get_transformers(@_) } } @{ $self->_elements }; |
|
26
|
|
|
|
|
47
|
|
|
26
|
|
|
|
|
86
|
|
|
11
|
|
|
|
|
340
|
|
104
|
|
|
|
|
|
|
|
105
|
11
|
|
|
|
|
44
|
return _filter_components( \%args, \@x ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_errors { |
109
|
317
|
|
|
317
|
|
643
|
my $self = shift; |
110
|
317
|
|
|
|
|
1036
|
my %args = _parse_args(@_); |
111
|
|
|
|
|
|
|
|
112
|
317
|
|
|
|
|
594
|
my @x = @{ $self->_errors }; |
|
317
|
|
|
|
|
10205
|
|
113
|
|
|
|
|
|
|
|
114
|
317
|
|
|
|
|
672
|
push @x, map { @{ $_->get_errors(@_) } } @{ $self->_elements }; |
|
907
|
|
|
|
|
1430
|
|
|
907
|
|
|
|
|
2419
|
|
|
317
|
|
|
|
|
9013
|
|
115
|
|
|
|
|
|
|
|
116
|
317
|
|
|
|
|
1037
|
_filter_components( \%args, \@x ); |
117
|
|
|
|
|
|
|
|
118
|
317
|
100
|
|
|
|
904
|
if ( !$args{forced} ) { |
119
|
230
|
|
|
|
|
437
|
@x = grep { !$_->forced } @x; |
|
28
|
|
|
|
|
890
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
317
|
|
|
|
|
1094
|
return \@x; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub clear_errors { |
126
|
82
|
|
|
82
|
|
251
|
my ($self) = @_; |
127
|
|
|
|
|
|
|
|
128
|
82
|
|
|
|
|
2581
|
$self->_errors( [] ); |
129
|
|
|
|
|
|
|
|
130
|
82
|
|
|
|
|
156
|
map { $_->clear_errors } @{ $self->_elements }; |
|
135
|
|
|
|
|
530
|
|
|
82
|
|
|
|
|
2466
|
|
131
|
|
|
|
|
|
|
|
132
|
82
|
|
|
|
|
268
|
return; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub render_data { |
136
|
34
|
|
|
34
|
|
101
|
my $self = shift; |
137
|
|
|
|
|
|
|
|
138
|
34
|
|
|
|
|
556
|
my $render = $self->SUPER::render_data(@_); |
139
|
|
|
|
|
|
|
|
140
|
34
|
50
|
|
|
|
77
|
map { delete $_->{container_tag} } @{ $render->{elements} || [] }; |
|
66
|
|
|
|
|
181
|
|
|
34
|
|
|
|
|
155
|
|
141
|
|
|
|
|
|
|
|
142
|
34
|
|
|
|
|
108
|
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
|
|
216
|
my ( $self, $render ) = @_; |
157
|
|
|
|
|
|
|
|
158
|
73
|
|
|
|
|
312
|
my @html = ( sprintf "<span%s>", process_attrs( $render->{attributes} ), ); |
159
|
|
|
|
|
|
|
|
160
|
73
|
|
|
|
|
207
|
for my $elem ( @{ $self->get_elements } ) { |
|
73
|
|
|
|
|
485
|
|
161
|
218
|
|
|
|
|
902
|
my $render = $elem->render_data; |
162
|
|
|
|
|
|
|
|
163
|
218
|
100
|
|
|
|
684
|
next if !defined $render; |
164
|
|
|
|
|
|
|
|
165
|
217
|
|
|
|
|
537
|
$render->{container_tag} = undef; |
166
|
|
|
|
|
|
|
|
167
|
217
|
|
|
|
|
913
|
push @html, |
168
|
|
|
|
|
|
|
$elem->string( |
169
|
|
|
|
|
|
|
{ render_data => $render, layout => $elem->multi_layout } ); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
73
|
|
|
|
|
288
|
push @html, "</span>"; |
173
|
|
|
|
|
|
|
|
174
|
73
|
|
|
|
|
1061
|
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
|
|
|
|
|
|
|
=pod |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=encoding UTF-8 |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 NAME |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
HTML::FormFu::Element::Multi - Combine multiple fields in a single element |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 VERSION |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
version 2.07 |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 SYNOPSIS |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
my $e = $form->element( Multi => 'foo' ); |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 DESCRIPTION |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Combine multiple form fields in a single logical element. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Non-field elements cannot be added as children of the Multi element. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 RENDERING NOTES |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
If the Multi element is rendered with the default 'string' render-method, |
220
|
|
|
|
|
|
|
all child fields will be rendered with the 'string' render-method, regardless |
221
|
|
|
|
|
|
|
of their L<HTML::FormFu/render_method> value. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Likewise, if the Multi element is rendered with the 'tt' render-method, |
224
|
|
|
|
|
|
|
all child fields will be rendered with the 'tt' render-method, regardless of |
225
|
|
|
|
|
|
|
their L<HTML::FormFu/render_method> value. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 SEE ALSO |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Is a sub-class of, and inherits methods from |
230
|
|
|
|
|
|
|
L<HTML::FormFu::Role::Element::Field>, |
231
|
|
|
|
|
|
|
L<HTML::FormFu::Element> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
L<HTML::FormFu> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 AUTHOR |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 LICENSE |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
242
|
|
|
|
|
|
|
the same terms as Perl itself. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Carl Franks <cpan@fireartist.com> |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Carl Franks. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
253
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |