| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormFu::Role::FormAndElementMethods; |
|
2
|
|
|
|
|
|
|
|
|
3
|
400
|
|
|
400
|
|
162838
|
use strict; |
|
|
400
|
|
|
|
|
548
|
|
|
|
400
|
|
|
|
|
14884
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
400
|
|
|
400
|
|
1438
|
use Moose::Role; |
|
|
400
|
|
|
|
|
514
|
|
|
|
400
|
|
|
|
|
2015
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
400
|
|
|
|
|
22509
|
use HTML::FormFu::Attribute qw( |
|
9
|
|
|
|
|
|
|
mk_attrs |
|
10
|
|
|
|
|
|
|
mk_attr_accessors |
|
11
|
|
|
|
|
|
|
mk_inherited_accessors |
|
12
|
|
|
|
|
|
|
mk_inherited_merging_accessors |
|
13
|
400
|
|
|
400
|
|
1307284
|
); |
|
|
400
|
|
|
|
|
609
|
|
|
14
|
400
|
|
|
|
|
15088
|
use HTML::FormFu::Util qw( |
|
15
|
|
|
|
|
|
|
require_class |
|
16
|
|
|
|
|
|
|
_merge_hashes |
|
17
|
400
|
|
|
400
|
|
1519
|
); |
|
|
400
|
|
|
|
|
507
|
|
|
18
|
400
|
|
|
400
|
|
1871
|
use Carp qw( croak ); |
|
|
400
|
|
|
|
|
504
|
|
|
|
400
|
|
|
|
|
14112
|
|
|
19
|
400
|
|
|
400
|
|
1503
|
use Scalar::Util qw( blessed refaddr ); |
|
|
400
|
|
|
|
|
505
|
|
|
|
400
|
|
|
|
|
529114
|
|
|
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 = ( |
|
44
|
|
|
|
|
|
|
@ATTRS, |
|
45
|
|
|
|
|
|
|
@ATTR_ACCESSOR, |
|
46
|
|
|
|
|
|
|
@INHERITED, |
|
47
|
|
|
|
|
|
|
@MERGING, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _require_deflator { |
|
51
|
28
|
|
|
28
|
|
57
|
my ( $self, $type, $opt ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
28
|
50
|
|
|
|
101
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
|
54
|
|
|
|
|
|
|
|
|
55
|
28
|
|
|
|
|
54
|
eval { my %x = %$opt }; |
|
|
28
|
|
|
|
|
97
|
|
|
56
|
28
|
50
|
|
|
|
71
|
croak "options argument must be hash-ref" if $@; |
|
57
|
|
|
|
|
|
|
|
|
58
|
28
|
|
|
|
|
40
|
my $class = $type; |
|
59
|
28
|
100
|
|
|
|
107
|
if ( not $class =~ s/^\+// ) { |
|
60
|
27
|
|
|
|
|
71
|
$class = "HTML::FormFu::Deflator::$class"; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
28
|
|
|
|
|
66
|
$type =~ s/^\+//; |
|
64
|
|
|
|
|
|
|
|
|
65
|
28
|
|
|
|
|
129
|
require_class($class); |
|
66
|
|
|
|
|
|
|
|
|
67
|
28
|
|
|
|
|
910
|
my $object = $class->new( { |
|
68
|
|
|
|
|
|
|
type => $type, |
|
69
|
|
|
|
|
|
|
parent => $self, |
|
70
|
|
|
|
|
|
|
} ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# handle default_args |
|
73
|
28
|
|
|
|
|
149
|
my $parent = $self->parent; |
|
74
|
|
|
|
|
|
|
|
|
75
|
28
|
50
|
|
|
|
139
|
if ( exists $parent->default_args->{deflators}{$type} ) { |
|
76
|
|
|
|
|
|
|
$opt |
|
77
|
0
|
|
|
|
|
0
|
= _merge_hashes( $parent->default_args->{deflators}{$type}, $opt, ); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
28
|
|
|
|
|
93
|
$object->populate($opt); |
|
81
|
|
|
|
|
|
|
|
|
82
|
28
|
|
|
|
|
97
|
return $object; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _require_filter { |
|
86
|
77
|
|
|
77
|
|
134
|
my ( $self, $type, $opt ) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
77
|
50
|
|
|
|
232
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
|
89
|
|
|
|
|
|
|
|
|
90
|
77
|
|
|
|
|
109
|
eval { my %x = %$opt }; |
|
|
77
|
|
|
|
|
211
|
|
|
91
|
77
|
50
|
|
|
|
177
|
croak "options argument must be hash-ref" if $@; |
|
92
|
|
|
|
|
|
|
|
|
93
|
77
|
|
|
|
|
102
|
my $class = $type; |
|
94
|
77
|
50
|
|
|
|
210
|
if ( not $class =~ s/^\+// ) { |
|
95
|
77
|
|
|
|
|
153
|
$class = "HTML::FormFu::Filter::$class"; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
77
|
|
|
|
|
117
|
$type =~ s/^\+//; |
|
99
|
|
|
|
|
|
|
|
|
100
|
77
|
|
|
|
|
227
|
require_class($class); |
|
101
|
|
|
|
|
|
|
|
|
102
|
77
|
|
|
|
|
2242
|
my $object = $class->new( { |
|
103
|
|
|
|
|
|
|
type => $type, |
|
104
|
|
|
|
|
|
|
parent => $self, |
|
105
|
|
|
|
|
|
|
} ); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# handle default_args |
|
108
|
77
|
|
|
|
|
338
|
my $parent = $self->parent; |
|
109
|
|
|
|
|
|
|
|
|
110
|
77
|
50
|
|
|
|
291
|
if ( exists $parent->default_args->{filters}{$type} ) { |
|
111
|
0
|
|
|
|
|
0
|
$opt = _merge_hashes( $parent->default_args->{filters}{$type}, $opt, ); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
77
|
|
|
|
|
207
|
$object->populate($opt); |
|
115
|
|
|
|
|
|
|
|
|
116
|
77
|
|
|
|
|
552
|
return $object; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _require_inflator { |
|
120
|
34
|
|
|
34
|
|
69
|
my ( $self, $type, $opt ) = @_; |
|
121
|
|
|
|
|
|
|
|
|
122
|
34
|
50
|
|
|
|
122
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
|
123
|
|
|
|
|
|
|
|
|
124
|
34
|
|
|
|
|
58
|
eval { my %x = %$opt }; |
|
|
34
|
|
|
|
|
117
|
|
|
125
|
34
|
50
|
|
|
|
121
|
croak "options argument must be hash-ref" if $@; |
|
126
|
|
|
|
|
|
|
|
|
127
|
34
|
|
|
|
|
51
|
my $class = $type; |
|
128
|
34
|
50
|
|
|
|
136
|
if ( not $class =~ s/^\+// ) { |
|
129
|
34
|
|
|
|
|
92
|
$class = "HTML::FormFu::Inflator::$class"; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
34
|
|
|
|
|
66
|
$type =~ s/^\+//; |
|
133
|
|
|
|
|
|
|
|
|
134
|
34
|
|
|
|
|
115
|
require_class($class); |
|
135
|
|
|
|
|
|
|
|
|
136
|
34
|
|
|
|
|
1082
|
my $object = $class->new( { |
|
137
|
|
|
|
|
|
|
type => $type, |
|
138
|
|
|
|
|
|
|
parent => $self, |
|
139
|
|
|
|
|
|
|
} ); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# handle default_args |
|
142
|
34
|
|
|
|
|
235
|
my $parent = $self->parent; |
|
143
|
|
|
|
|
|
|
|
|
144
|
34
|
50
|
|
|
|
188
|
if ( exists $parent->default_args->{inflators}{$type} ) { |
|
145
|
|
|
|
|
|
|
$opt |
|
146
|
0
|
|
|
|
|
0
|
= _merge_hashes( $parent->default_args->{inflators}{$type}, $opt, ); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
34
|
|
|
|
|
125
|
$object->populate($opt); |
|
150
|
|
|
|
|
|
|
|
|
151
|
34
|
|
|
|
|
160
|
return $object; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub _require_validator { |
|
155
|
6
|
|
|
6
|
|
17
|
my ( $self, $type, $opt ) = @_; |
|
156
|
|
|
|
|
|
|
|
|
157
|
6
|
50
|
|
|
|
17
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
|
158
|
|
|
|
|
|
|
|
|
159
|
6
|
|
|
|
|
8
|
eval { my %x = %$opt }; |
|
|
6
|
|
|
|
|
15
|
|
|
160
|
6
|
50
|
|
|
|
15
|
croak "options argument must be hash-ref" if $@; |
|
161
|
|
|
|
|
|
|
|
|
162
|
6
|
|
|
|
|
8
|
my $class = $type; |
|
163
|
6
|
100
|
|
|
|
22
|
if ( not $class =~ s/^\+// ) { |
|
164
|
4
|
|
|
|
|
10
|
$class = "HTML::FormFu::Validator::$class"; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
6
|
|
|
|
|
12
|
$type =~ s/^\+//; |
|
168
|
|
|
|
|
|
|
|
|
169
|
6
|
|
|
|
|
18
|
require_class($class); |
|
170
|
|
|
|
|
|
|
|
|
171
|
6
|
|
|
|
|
183
|
my $object = $class->new( { |
|
172
|
|
|
|
|
|
|
type => $type, |
|
173
|
|
|
|
|
|
|
parent => $self, |
|
174
|
|
|
|
|
|
|
} ); |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# handle default_args |
|
177
|
6
|
|
|
|
|
36
|
my $parent = $self->parent; |
|
178
|
|
|
|
|
|
|
|
|
179
|
6
|
50
|
|
|
|
30
|
if ( exists $parent->default_args->{validators}{$type} ) { |
|
180
|
0
|
|
|
|
|
0
|
%$opt = ( %{ $parent->default_args->{validators}{$type} }, %$opt ); |
|
|
0
|
|
|
|
|
0
|
|
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
6
|
|
|
|
|
16
|
$object->populate($opt); |
|
184
|
|
|
|
|
|
|
|
|
185
|
6
|
|
|
|
|
19
|
return $object; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _require_transformer { |
|
189
|
5
|
|
|
5
|
|
8
|
my ( $self, $type, $opt ) = @_; |
|
190
|
|
|
|
|
|
|
|
|
191
|
5
|
50
|
|
|
|
12
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
|
192
|
|
|
|
|
|
|
|
|
193
|
5
|
|
|
|
|
9
|
eval { my %x = %$opt }; |
|
|
5
|
|
|
|
|
13
|
|
|
194
|
5
|
50
|
|
|
|
10
|
croak "options argument must be hash-ref" if $@; |
|
195
|
|
|
|
|
|
|
|
|
196
|
5
|
|
|
|
|
7
|
my $class = $type; |
|
197
|
5
|
50
|
|
|
|
17
|
if ( not $class =~ s/^\+// ) { |
|
198
|
5
|
|
|
|
|
12
|
$class = "HTML::FormFu::Transformer::$class"; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
5
|
|
|
|
|
8
|
$type =~ s/^\+//; |
|
202
|
|
|
|
|
|
|
|
|
203
|
5
|
|
|
|
|
13
|
require_class($class); |
|
204
|
|
|
|
|
|
|
|
|
205
|
5
|
|
|
|
|
146
|
my $object = $class->new( { |
|
206
|
|
|
|
|
|
|
type => $type, |
|
207
|
|
|
|
|
|
|
parent => $self, |
|
208
|
|
|
|
|
|
|
} ); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# handle default_args |
|
211
|
5
|
|
|
|
|
17
|
my $parent = $self->parent; |
|
212
|
|
|
|
|
|
|
|
|
213
|
5
|
50
|
|
|
|
22
|
if ( exists $parent->default_args->{transformers}{$type} ) { |
|
214
|
|
|
|
|
|
|
$opt |
|
215
|
0
|
|
|
|
|
0
|
= _merge_hashes( $parent->default_args->{transformers}{$type}, $opt, |
|
216
|
|
|
|
|
|
|
); |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
5
|
|
|
|
|
14
|
$object->populate($opt); |
|
220
|
|
|
|
|
|
|
|
|
221
|
5
|
|
|
|
|
11
|
return $object; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub _require_plugin { |
|
225
|
2
|
|
|
2
|
|
3
|
my ( $self, $type, $arg ) = @_; |
|
226
|
|
|
|
|
|
|
|
|
227
|
2
|
50
|
|
|
|
6
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
|
228
|
|
|
|
|
|
|
|
|
229
|
2
|
|
|
|
|
6
|
eval { my %x = %$arg }; |
|
|
2
|
|
|
|
|
5
|
|
|
230
|
2
|
50
|
|
|
|
6
|
croak "options argument must be hash-ref" if $@; |
|
231
|
|
|
|
|
|
|
|
|
232
|
2
|
|
|
|
|
5
|
my $abs = $type =~ s/^\+//; |
|
233
|
2
|
|
|
|
|
3
|
my $class = $type; |
|
234
|
|
|
|
|
|
|
|
|
235
|
2
|
50
|
|
|
|
4
|
if ( !$abs ) { |
|
236
|
2
|
|
|
|
|
6
|
$class = "HTML::FormFu::Plugin::$class"; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
2
|
|
|
|
|
3
|
$type =~ s/^\+//; |
|
240
|
|
|
|
|
|
|
|
|
241
|
2
|
|
|
|
|
7
|
require_class($class); |
|
242
|
|
|
|
|
|
|
|
|
243
|
2
|
|
|
|
|
62
|
my $plugin = $class->new( { |
|
244
|
|
|
|
|
|
|
type => $type, |
|
245
|
|
|
|
|
|
|
parent => $self, |
|
246
|
|
|
|
|
|
|
} ); |
|
247
|
|
|
|
|
|
|
|
|
248
|
2
|
|
|
|
|
7
|
$plugin->populate($arg); |
|
249
|
|
|
|
|
|
|
|
|
250
|
2
|
|
|
|
|
8
|
return $plugin; |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub get_deflator { |
|
254
|
7
|
|
|
7
|
0
|
2167
|
my $self = shift; |
|
255
|
|
|
|
|
|
|
|
|
256
|
7
|
|
|
|
|
21
|
my $x = $self->get_deflators(@_); |
|
257
|
|
|
|
|
|
|
|
|
258
|
7
|
100
|
|
|
|
26
|
return @$x ? $x->[0] : (); |
|
259
|
|
|
|
|
|
|
} |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub get_filter { |
|
262
|
4
|
|
|
4
|
0
|
1850
|
my $self = shift; |
|
263
|
|
|
|
|
|
|
|
|
264
|
4
|
|
|
|
|
14
|
my $x = $self->get_filters(@_); |
|
265
|
|
|
|
|
|
|
|
|
266
|
4
|
50
|
|
|
|
17
|
return @$x ? $x->[0] : (); |
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub get_constraint { |
|
270
|
23
|
|
|
23
|
0
|
1813
|
my $self = shift; |
|
271
|
|
|
|
|
|
|
|
|
272
|
23
|
|
|
|
|
95
|
my $x = $self->get_constraints(@_); |
|
273
|
|
|
|
|
|
|
|
|
274
|
23
|
100
|
|
|
|
250
|
return @$x ? $x->[0] : (); |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub get_inflator { |
|
278
|
7
|
|
|
7
|
0
|
2289
|
my $self = shift; |
|
279
|
|
|
|
|
|
|
|
|
280
|
7
|
|
|
|
|
22
|
my $x = $self->get_inflators(@_); |
|
281
|
|
|
|
|
|
|
|
|
282
|
7
|
100
|
|
|
|
25
|
return @$x ? $x->[0] : (); |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub get_validator { |
|
286
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
287
|
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
0
|
my $x = $self->get_validators(@_); |
|
289
|
|
|
|
|
|
|
|
|
290
|
0
|
0
|
|
|
|
0
|
return @$x ? $x->[0] : (); |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub get_transformer { |
|
294
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
295
|
|
|
|
|
|
|
|
|
296
|
0
|
|
|
|
|
0
|
my $x = $self->get_transformers(@_); |
|
297
|
|
|
|
|
|
|
|
|
298
|
0
|
0
|
|
|
|
0
|
return @$x ? $x->[0] : (); |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub get_plugin { |
|
302
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
303
|
|
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
0
|
my $x = $self->get_plugins(@_); |
|
305
|
|
|
|
|
|
|
|
|
306
|
0
|
0
|
|
|
|
0
|
return @$x ? $x->[0] : (); |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
sub model_config { |
|
310
|
476
|
|
|
476
|
0
|
519
|
my ( $self, $config ) = @_; |
|
311
|
|
|
|
|
|
|
|
|
312
|
476
|
|
100
|
|
|
1720
|
$self->{model_config} ||= {}; |
|
313
|
|
|
|
|
|
|
|
|
314
|
476
|
|
|
|
|
1307
|
$self->{model_config} = _merge_hashes( $self->{model_config}, $config ); |
|
315
|
|
|
|
|
|
|
|
|
316
|
476
|
|
|
|
|
1248
|
return $self->{model_config}; |
|
317
|
|
|
|
|
|
|
} |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub _string_equals { |
|
320
|
85
|
|
|
85
|
|
13499
|
my ( $a, $b ) = @_; |
|
321
|
|
|
|
|
|
|
|
|
322
|
85
|
100
|
|
|
|
913
|
return blessed($b) |
|
323
|
|
|
|
|
|
|
? ( refaddr($a) eq refaddr($b) ) |
|
324
|
|
|
|
|
|
|
: ( "$a" eq "$b" ); |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub _object_equals { |
|
328
|
202
|
|
|
202
|
|
18926
|
my ( $a, $b ) = @_; |
|
329
|
|
|
|
|
|
|
|
|
330
|
202
|
50
|
|
|
|
1415
|
return blessed($b) |
|
331
|
|
|
|
|
|
|
? ( refaddr($a) eq refaddr($b) ) |
|
332
|
|
|
|
|
|
|
: undef; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
1; |