line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
404
|
|
|
404
|
|
220798
|
use strict; |
|
404
|
|
|
|
|
1074
|
|
|
404
|
|
|
|
|
21770
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::FormFu::Role::FormAndElementMethods; |
4
|
|
|
|
|
|
|
# ABSTRACT: role for form and element methods |
5
|
|
|
|
|
|
|
$HTML::FormFu::Role::FormAndElementMethods::VERSION = '2.07'; |
6
|
404
|
|
|
404
|
|
2629
|
use Moose::Role; |
|
404
|
|
|
|
|
936
|
|
|
404
|
|
|
|
|
2849
|
|
7
|
|
|
|
|
|
|
|
8
|
404
|
|
|
|
|
30048
|
use HTML::FormFu::Attribute qw( |
9
|
|
|
|
|
|
|
mk_attrs |
10
|
|
|
|
|
|
|
mk_attr_accessors |
11
|
|
|
|
|
|
|
mk_inherited_accessors |
12
|
|
|
|
|
|
|
mk_inherited_merging_accessors |
13
|
404
|
|
|
404
|
|
2128220
|
); |
|
404
|
|
|
|
|
1062
|
|
14
|
404
|
|
|
|
|
21087
|
use HTML::FormFu::Util qw( |
15
|
|
|
|
|
|
|
require_class |
16
|
|
|
|
|
|
|
_merge_hashes |
17
|
404
|
|
|
404
|
|
2874
|
); |
|
404
|
|
|
|
|
1081
|
|
18
|
404
|
|
|
404
|
|
2740
|
use Carp qw( croak ); |
|
404
|
|
|
|
|
1010
|
|
|
404
|
|
|
|
|
19696
|
|
19
|
404
|
|
|
404
|
|
2812
|
use Scalar::Util qw( blessed refaddr ); |
|
404
|
|
|
|
|
1090
|
|
|
404
|
|
|
|
|
758578
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @ATTRS = (qw( attributes )); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->mk_attrs(@ATTRS); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my @ATTR_ACCESSOR = (qw( title )); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->mk_attr_accessors(@ATTR_ACCESSOR); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my @INHERITED = qw( |
30
|
|
|
|
|
|
|
render_method |
31
|
|
|
|
|
|
|
config_file_path |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->mk_inherited_accessors(@INHERITED); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @MERGING = qw( |
37
|
|
|
|
|
|
|
tt_args |
38
|
|
|
|
|
|
|
config_callback |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__PACKAGE__->mk_inherited_merging_accessors(@MERGING); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our @MULTIFORM_SHARED = ( @ATTRS, @ATTR_ACCESSOR, @INHERITED, @MERGING, ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _require_deflator { |
46
|
28
|
|
|
28
|
|
101
|
my ( $self, $type, $opt ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
28
|
50
|
|
|
|
174
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
49
|
|
|
|
|
|
|
|
50
|
28
|
|
|
|
|
97
|
eval { my %x = %$opt }; |
|
28
|
|
|
|
|
123
|
|
51
|
28
|
50
|
|
|
|
110
|
croak "options argument must be hash-ref" if $@; |
52
|
|
|
|
|
|
|
|
53
|
28
|
|
|
|
|
68
|
my $class = $type; |
54
|
28
|
100
|
|
|
|
132
|
if ( not $class =~ s/^\+// ) { |
55
|
27
|
|
|
|
|
100
|
$class = "HTML::FormFu::Deflator::$class"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
28
|
|
|
|
|
80
|
$type =~ s/^\+//; |
59
|
|
|
|
|
|
|
|
60
|
28
|
|
|
|
|
174
|
require_class($class); |
61
|
|
|
|
|
|
|
|
62
|
28
|
|
|
|
|
1139
|
my $object = $class->new( |
63
|
|
|
|
|
|
|
{ type => $type, |
64
|
|
|
|
|
|
|
parent => $self, |
65
|
|
|
|
|
|
|
} ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# handle default_args |
68
|
28
|
|
|
|
|
171
|
my $parent = $self->parent; |
69
|
|
|
|
|
|
|
|
70
|
28
|
50
|
|
|
|
173
|
if ( exists $parent->default_args->{deflators}{$type} ) { |
71
|
|
|
|
|
|
|
$opt |
72
|
0
|
|
|
|
|
0
|
= _merge_hashes( $parent->default_args->{deflators}{$type}, $opt, ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
28
|
|
|
|
|
137
|
$object->populate($opt); |
76
|
|
|
|
|
|
|
|
77
|
28
|
|
|
|
|
121
|
return $object; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _require_filter { |
81
|
77
|
|
|
77
|
|
265
|
my ( $self, $type, $opt ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
77
|
50
|
|
|
|
288
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
84
|
|
|
|
|
|
|
|
85
|
77
|
|
|
|
|
184
|
eval { my %x = %$opt }; |
|
77
|
|
|
|
|
306
|
|
86
|
77
|
50
|
|
|
|
279
|
croak "options argument must be hash-ref" if $@; |
87
|
|
|
|
|
|
|
|
88
|
77
|
|
|
|
|
190
|
my $class = $type; |
89
|
77
|
50
|
|
|
|
331
|
if ( not $class =~ s/^\+// ) { |
90
|
77
|
|
|
|
|
280
|
$class = "HTML::FormFu::Filter::$class"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
77
|
|
|
|
|
213
|
$type =~ s/^\+//; |
94
|
|
|
|
|
|
|
|
95
|
77
|
|
|
|
|
350
|
require_class($class); |
96
|
|
|
|
|
|
|
|
97
|
77
|
|
|
|
|
2732
|
my $object = $class->new( |
98
|
|
|
|
|
|
|
{ type => $type, |
99
|
|
|
|
|
|
|
parent => $self, |
100
|
|
|
|
|
|
|
} ); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# handle default_args |
103
|
77
|
|
|
|
|
398
|
my $parent = $self->parent; |
104
|
|
|
|
|
|
|
|
105
|
77
|
50
|
|
|
|
432
|
if ( exists $parent->default_args->{filters}{$type} ) { |
106
|
0
|
|
|
|
|
0
|
$opt = _merge_hashes( $parent->default_args->{filters}{$type}, $opt, ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
77
|
|
|
|
|
312
|
$object->populate($opt); |
110
|
|
|
|
|
|
|
|
111
|
77
|
|
|
|
|
296
|
return $object; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _require_inflator { |
115
|
34
|
|
|
34
|
|
130
|
my ( $self, $type, $opt ) = @_; |
116
|
|
|
|
|
|
|
|
117
|
34
|
50
|
|
|
|
203
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
118
|
|
|
|
|
|
|
|
119
|
34
|
|
|
|
|
93
|
eval { my %x = %$opt }; |
|
34
|
|
|
|
|
178
|
|
120
|
34
|
50
|
|
|
|
141
|
croak "options argument must be hash-ref" if $@; |
121
|
|
|
|
|
|
|
|
122
|
34
|
|
|
|
|
103
|
my $class = $type; |
123
|
34
|
50
|
|
|
|
169
|
if ( not $class =~ s/^\+// ) { |
124
|
34
|
|
|
|
|
142
|
$class = "HTML::FormFu::Inflator::$class"; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
34
|
|
|
|
|
117
|
$type =~ s/^\+//; |
128
|
|
|
|
|
|
|
|
129
|
34
|
|
|
|
|
189
|
require_class($class); |
130
|
|
|
|
|
|
|
|
131
|
34
|
|
|
|
|
1428
|
my $object = $class->new( |
132
|
|
|
|
|
|
|
{ type => $type, |
133
|
|
|
|
|
|
|
parent => $self, |
134
|
|
|
|
|
|
|
} ); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# handle default_args |
137
|
34
|
|
|
|
|
292
|
my $parent = $self->parent; |
138
|
|
|
|
|
|
|
|
139
|
34
|
50
|
|
|
|
246
|
if ( exists $parent->default_args->{inflators}{$type} ) { |
140
|
|
|
|
|
|
|
$opt |
141
|
0
|
|
|
|
|
0
|
= _merge_hashes( $parent->default_args->{inflators}{$type}, $opt, ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
34
|
|
|
|
|
206
|
$object->populate($opt); |
145
|
|
|
|
|
|
|
|
146
|
34
|
|
|
|
|
155
|
return $object; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub _require_validator { |
150
|
6
|
|
|
6
|
|
23
|
my ( $self, $type, $opt ) = @_; |
151
|
|
|
|
|
|
|
|
152
|
6
|
50
|
|
|
|
24
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
153
|
|
|
|
|
|
|
|
154
|
6
|
|
|
|
|
13
|
eval { my %x = %$opt }; |
|
6
|
|
|
|
|
24
|
|
155
|
6
|
50
|
|
|
|
34
|
croak "options argument must be hash-ref" if $@; |
156
|
|
|
|
|
|
|
|
157
|
6
|
|
|
|
|
24
|
my $class = $type; |
158
|
6
|
100
|
|
|
|
42
|
if ( not $class =~ s/^\+// ) { |
159
|
4
|
|
|
|
|
14
|
$class = "HTML::FormFu::Validator::$class"; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
6
|
|
|
|
|
21
|
$type =~ s/^\+//; |
163
|
|
|
|
|
|
|
|
164
|
6
|
|
|
|
|
25
|
require_class($class); |
165
|
|
|
|
|
|
|
|
166
|
6
|
|
|
|
|
233
|
my $object = $class->new( |
167
|
|
|
|
|
|
|
{ type => $type, |
168
|
|
|
|
|
|
|
parent => $self, |
169
|
|
|
|
|
|
|
} ); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# handle default_args |
172
|
6
|
|
|
|
|
52
|
my $parent = $self->parent; |
173
|
|
|
|
|
|
|
|
174
|
6
|
50
|
|
|
|
44
|
if ( exists $parent->default_args->{validators}{$type} ) { |
175
|
0
|
|
|
|
|
0
|
%$opt = ( %{ $parent->default_args->{validators}{$type} }, %$opt ); |
|
0
|
|
|
|
|
0
|
|
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
6
|
|
|
|
|
25
|
$object->populate($opt); |
179
|
|
|
|
|
|
|
|
180
|
6
|
|
|
|
|
23
|
return $object; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub _require_transformer { |
184
|
5
|
|
|
5
|
|
18
|
my ( $self, $type, $opt ) = @_; |
185
|
|
|
|
|
|
|
|
186
|
5
|
50
|
|
|
|
25
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
187
|
|
|
|
|
|
|
|
188
|
5
|
|
|
|
|
12
|
eval { my %x = %$opt }; |
|
5
|
|
|
|
|
17
|
|
189
|
5
|
50
|
|
|
|
15
|
croak "options argument must be hash-ref" if $@; |
190
|
|
|
|
|
|
|
|
191
|
5
|
|
|
|
|
20
|
my $class = $type; |
192
|
5
|
50
|
|
|
|
22
|
if ( not $class =~ s/^\+// ) { |
193
|
5
|
|
|
|
|
25
|
$class = "HTML::FormFu::Transformer::$class"; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
5
|
|
|
|
|
15
|
$type =~ s/^\+//; |
197
|
|
|
|
|
|
|
|
198
|
5
|
|
|
|
|
22
|
require_class($class); |
199
|
|
|
|
|
|
|
|
200
|
5
|
|
|
|
|
184
|
my $object = $class->new( |
201
|
|
|
|
|
|
|
{ type => $type, |
202
|
|
|
|
|
|
|
parent => $self, |
203
|
|
|
|
|
|
|
} ); |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# handle default_args |
206
|
5
|
|
|
|
|
28
|
my $parent = $self->parent; |
207
|
|
|
|
|
|
|
|
208
|
5
|
50
|
|
|
|
33
|
if ( exists $parent->default_args->{transformers}{$type} ) { |
209
|
|
|
|
|
|
|
$opt |
210
|
0
|
|
|
|
|
0
|
= _merge_hashes( $parent->default_args->{transformers}{$type}, |
211
|
|
|
|
|
|
|
$opt, ); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
5
|
|
|
|
|
22
|
$object->populate($opt); |
215
|
|
|
|
|
|
|
|
216
|
5
|
|
|
|
|
18
|
return $object; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub _require_plugin { |
220
|
2
|
|
|
2
|
|
8
|
my ( $self, $type, $arg ) = @_; |
221
|
|
|
|
|
|
|
|
222
|
2
|
50
|
|
|
|
9
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
223
|
|
|
|
|
|
|
|
224
|
2
|
|
|
|
|
5
|
eval { my %x = %$arg }; |
|
2
|
|
|
|
|
8
|
|
225
|
2
|
50
|
|
|
|
8
|
croak "options argument must be hash-ref" if $@; |
226
|
|
|
|
|
|
|
|
227
|
2
|
|
|
|
|
9
|
my $abs = $type =~ s/^\+//; |
228
|
2
|
|
|
|
|
13
|
my $class = $type; |
229
|
|
|
|
|
|
|
|
230
|
2
|
50
|
|
|
|
15
|
if ( !$abs ) { |
231
|
2
|
|
|
|
|
9
|
$class = "HTML::FormFu::Plugin::$class"; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
2
|
|
|
|
|
7
|
$type =~ s/^\+//; |
235
|
|
|
|
|
|
|
|
236
|
2
|
|
|
|
|
10
|
require_class($class); |
237
|
|
|
|
|
|
|
|
238
|
2
|
|
|
|
|
78
|
my $plugin = $class->new( |
239
|
|
|
|
|
|
|
{ type => $type, |
240
|
|
|
|
|
|
|
parent => $self, |
241
|
|
|
|
|
|
|
} ); |
242
|
|
|
|
|
|
|
|
243
|
2
|
|
|
|
|
12
|
$plugin->populate($arg); |
244
|
|
|
|
|
|
|
|
245
|
2
|
|
|
|
|
9
|
return $plugin; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub get_deflator { |
249
|
7
|
|
|
7
|
0
|
3984
|
my $self = shift; |
250
|
|
|
|
|
|
|
|
251
|
7
|
|
|
|
|
29
|
my $x = $self->get_deflators(@_); |
252
|
|
|
|
|
|
|
|
253
|
7
|
100
|
|
|
|
37
|
return @$x ? $x->[0] : (); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub get_filter { |
257
|
4
|
|
|
4
|
0
|
2005
|
my $self = shift; |
258
|
|
|
|
|
|
|
|
259
|
4
|
|
|
|
|
17
|
my $x = $self->get_filters(@_); |
260
|
|
|
|
|
|
|
|
261
|
4
|
50
|
|
|
|
22
|
return @$x ? $x->[0] : (); |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub get_constraint { |
265
|
23
|
|
|
23
|
0
|
2184
|
my $self = shift; |
266
|
|
|
|
|
|
|
|
267
|
23
|
|
|
|
|
130
|
my $x = $self->get_constraints(@_); |
268
|
|
|
|
|
|
|
|
269
|
23
|
100
|
|
|
|
340
|
return @$x ? $x->[0] : (); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub get_inflator { |
273
|
7
|
|
|
7
|
0
|
5108
|
my $self = shift; |
274
|
|
|
|
|
|
|
|
275
|
7
|
|
|
|
|
30
|
my $x = $self->get_inflators(@_); |
276
|
|
|
|
|
|
|
|
277
|
7
|
100
|
|
|
|
40
|
return @$x ? $x->[0] : (); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub get_validator { |
281
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
282
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
0
|
my $x = $self->get_validators(@_); |
284
|
|
|
|
|
|
|
|
285
|
0
|
0
|
|
|
|
0
|
return @$x ? $x->[0] : (); |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub get_transformer { |
289
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
0
|
my $x = $self->get_transformers(@_); |
292
|
|
|
|
|
|
|
|
293
|
0
|
0
|
|
|
|
0
|
return @$x ? $x->[0] : (); |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub get_plugin { |
297
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
298
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
0
|
my $x = $self->get_plugins(@_); |
300
|
|
|
|
|
|
|
|
301
|
0
|
0
|
|
|
|
0
|
return @$x ? $x->[0] : (); |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub model_config { |
305
|
482
|
|
|
482
|
0
|
1117
|
my ( $self, $config ) = @_; |
306
|
|
|
|
|
|
|
|
307
|
482
|
|
100
|
|
|
2535
|
$self->{model_config} ||= {}; |
308
|
|
|
|
|
|
|
|
309
|
482
|
|
|
|
|
1863
|
$self->{model_config} = _merge_hashes( $self->{model_config}, $config ); |
310
|
|
|
|
|
|
|
|
311
|
482
|
|
|
|
|
1844
|
return $self->{model_config}; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub _string_equals { |
315
|
85
|
|
|
85
|
|
18717
|
my ( $a, $b ) = @_; |
316
|
|
|
|
|
|
|
|
317
|
85
|
100
|
|
|
|
802
|
return blessed($b) |
318
|
|
|
|
|
|
|
? ( refaddr($a) eq refaddr($b) ) |
319
|
|
|
|
|
|
|
: ( "$a" eq "$b" ); |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
sub _object_equals { |
323
|
202
|
|
|
202
|
|
26235
|
my ( $a, $b ) = @_; |
324
|
|
|
|
|
|
|
|
325
|
202
|
50
|
|
|
|
1956
|
return blessed($b) |
326
|
|
|
|
|
|
|
? ( refaddr($a) eq refaddr($b) ) |
327
|
|
|
|
|
|
|
: undef; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
1; |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
__END__ |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=pod |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=encoding UTF-8 |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head1 NAME |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
HTML::FormFu::Role::FormAndElementMethods - role for form and element methods |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=head1 VERSION |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
version 2.07 |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=head1 AUTHOR |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
Carl Franks <cpan@fireartist.com> |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Carl Franks. |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
355
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=cut |