line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Inline; |
2
|
|
|
|
|
|
|
$Form::Tiny::Inline::VERSION = '2.21'; |
3
|
11
|
|
|
11
|
|
885857
|
use v5.10; |
|
11
|
|
|
|
|
138
|
|
4
|
11
|
|
|
11
|
|
64
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
258
|
|
5
|
11
|
|
|
11
|
|
69
|
use warnings; |
|
11
|
|
|
|
|
36
|
|
|
11
|
|
|
|
|
1383
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub is |
8
|
|
|
|
|
|
|
{ |
9
|
6
|
|
|
6
|
1
|
3553
|
my ($class, @roles) = @_; |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
|
|
40
|
return Form::Tiny::Inline::Builder->create(@roles); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
48
|
|
|
48
|
1
|
19292
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
48
|
|
|
|
|
184
|
return Form::Tiny::Inline::Builder->create()->new(@params); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# actual inline form package |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Form::Tiny::Inline::Form; |
25
|
|
|
|
|
|
|
$Form::Tiny::Inline::Form::VERSION = '2.21'; |
26
|
11
|
|
|
11
|
|
135
|
use v5.10; |
|
11
|
|
|
|
|
35
|
|
27
|
11
|
|
|
11
|
|
430
|
use strict; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
237
|
|
28
|
11
|
|
|
11
|
|
52
|
use warnings; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
434
|
|
29
|
|
|
|
|
|
|
|
30
|
11
|
|
|
11
|
|
5385
|
use Types::Standard qw(InstanceOf); |
|
11
|
|
|
|
|
1067002
|
|
|
11
|
|
|
|
|
112
|
|
31
|
11
|
|
|
11
|
|
31831
|
use Moo; |
|
11
|
|
|
|
|
114912
|
|
|
11
|
|
|
|
|
87
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# NOTE: consume this role eagerly |
34
|
|
|
|
|
|
|
# normally, it is part of the Base plugin, but it is also needed to have proper set |
35
|
|
|
|
|
|
|
# of constructor parameters. Since inline forms will have roles merged into the |
36
|
|
|
|
|
|
|
# objects themselves, this needs to be done beforehand |
37
|
|
|
|
|
|
|
with 'Form::Tiny::Form'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has '_meta' => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => InstanceOf ['Form::Tiny::Meta'], |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub form_meta |
46
|
|
|
|
|
|
|
{ |
47
|
141
|
|
|
141
|
0
|
225
|
my ($self) = @_; |
48
|
141
|
|
|
|
|
459
|
return $self->_meta; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub BUILD |
52
|
|
|
|
|
|
|
{ |
53
|
47
|
|
|
47
|
0
|
8088
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
47
|
|
|
|
|
215
|
require Moo::Role; |
56
|
|
|
|
|
|
|
Moo::Role->apply_roles_to_object( |
57
|
0
|
|
|
|
|
0
|
$self, @{$self->_meta->form_roles} |
58
|
47
|
50
|
|
|
|
71
|
) if @{$self->_meta->form_roles}; |
|
47
|
|
|
|
|
540
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# builder package to allow adding meta roles with no package magic |
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package Form::Tiny::Inline::Builder; |
67
|
|
|
|
|
|
|
$Form::Tiny::Inline::Builder::VERSION = '2.21'; |
68
|
11
|
|
|
11
|
|
17633
|
use v5.10; |
|
11
|
|
|
|
|
57
|
|
69
|
11
|
|
|
11
|
|
65
|
use strict; |
|
11
|
|
|
|
|
34
|
|
|
11
|
|
|
|
|
285
|
|
70
|
11
|
|
|
11
|
|
93
|
use warnings; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
390
|
|
71
|
|
|
|
|
|
|
|
72
|
11
|
|
|
11
|
|
74
|
use Types::Standard qw(Str); |
|
11
|
|
|
|
|
52
|
|
|
11
|
|
|
|
|
98
|
|
73
|
|
|
|
|
|
|
|
74
|
11
|
|
|
11
|
|
20680
|
use Form::Tiny::Utils qw(trim create_anon_form_meta); |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
4759
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _build |
77
|
|
|
|
|
|
|
{ |
78
|
54
|
|
|
54
|
|
142
|
my ($self, %args) = @_; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# NOTE: called with caller = undef, context_ref = undef |
81
|
|
|
|
|
|
|
# not all plugins will be compatible with this, but that's okay |
82
|
54
|
|
|
|
|
3308
|
require Form::Tiny; |
83
|
54
|
|
|
|
|
120
|
my $wanted = Form::Tiny->ft_run_plugins(undef, undef, @{$self->{plugins}}); |
|
54
|
|
|
|
|
286
|
|
84
|
|
|
|
|
|
|
|
85
|
54
|
|
|
|
|
87
|
my $meta = create_anon_form_meta(@{$wanted->{meta_roles}}); |
|
54
|
|
|
|
|
179
|
|
86
|
54
|
|
|
|
|
937
|
$meta->set_form_roles($wanted->{roles}); |
87
|
54
|
|
|
|
|
1274
|
$meta->bootstrap; |
88
|
|
|
|
|
|
|
|
89
|
54
|
100
|
|
|
|
195
|
if ($args{fields}) { |
90
|
1
|
|
|
|
|
3
|
for my $field_name (keys %{$args{fields}}) { |
|
1
|
|
|
|
|
5
|
|
91
|
|
|
|
|
|
|
$meta->add_field( |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
name => $field_name, |
94
|
1
|
|
|
|
|
2
|
%{$args{fields}{$field_name}}, |
|
1
|
|
|
|
|
8
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
54
|
|
100
|
|
|
93
|
for my $field (@{$args{field_defs} // []}) { |
|
54
|
|
|
|
|
217
|
|
101
|
46
|
|
|
|
|
167
|
$meta->add_field($field); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
47
|
100
|
|
|
|
128
|
if ($args{cleaner}) { |
105
|
1
|
|
|
|
|
5
|
$meta->add_hook(cleanup => $args{cleaner}); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
47
|
100
|
|
|
|
256
|
if ($meta->can('add_filter')) { |
109
|
3
|
|
|
|
|
18
|
$meta->add_global_trim_filter; |
110
|
|
|
|
|
|
|
|
111
|
3
|
|
100
|
|
|
11
|
for my $filter (@{$args{filters} // []}) { |
|
3
|
|
|
|
|
24
|
|
112
|
1
|
|
|
|
|
5
|
$meta->add_filter(@$filter); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
47
|
|
|
|
|
881
|
return Form::Tiny::Inline::Form->new(%args, _meta => $meta); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub create |
120
|
|
|
|
|
|
|
{ |
121
|
54
|
|
|
54
|
|
128
|
my ($self, @plugins) = @_; |
122
|
|
|
|
|
|
|
|
123
|
54
|
|
|
|
|
208
|
@plugins = map { ucfirst lc $_ } @plugins; |
|
7
|
|
|
|
|
70
|
|
124
|
|
|
|
|
|
|
|
125
|
54
|
|
|
|
|
319
|
return bless { |
126
|
|
|
|
|
|
|
plugins => \@plugins |
127
|
|
|
|
|
|
|
}, $self; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub new |
131
|
|
|
|
|
|
|
{ |
132
|
54
|
|
|
54
|
|
134
|
my $self = shift; |
133
|
54
|
|
|
|
|
82
|
my %params; |
134
|
54
|
50
|
33
|
|
|
211
|
if (@_ == 1 && ref $_[0] eq 'HASH') { |
135
|
0
|
|
|
|
|
0
|
%params = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else { |
138
|
54
|
|
|
|
|
180
|
%params = @_; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
54
|
|
|
|
|
184
|
return $self->_build(%params); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |