line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Inline; |
2
|
|
|
|
|
|
|
$Form::Tiny::Inline::VERSION = '2.20'; |
3
|
11
|
|
|
11
|
|
959275
|
use v5.10; |
|
11
|
|
|
|
|
152
|
|
4
|
11
|
|
|
11
|
|
61
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
273
|
|
5
|
11
|
|
|
11
|
|
63
|
use warnings; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
1408
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub is |
8
|
|
|
|
|
|
|
{ |
9
|
6
|
|
|
6
|
1
|
4732
|
my ($class, @roles) = @_; |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
|
|
47
|
return Form::Tiny::Inline::Builder->create(@roles); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
48
|
|
|
48
|
1
|
19662
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
48
|
|
|
|
|
163
|
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.20'; |
26
|
11
|
|
|
11
|
|
126
|
use v5.10; |
|
11
|
|
|
|
|
35
|
|
27
|
11
|
|
|
11
|
|
66
|
use strict; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
254
|
|
28
|
11
|
|
|
11
|
|
51
|
use warnings; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
436
|
|
29
|
|
|
|
|
|
|
|
30
|
11
|
|
|
11
|
|
5696
|
use Types::Standard qw(InstanceOf); |
|
11
|
|
|
|
|
1097379
|
|
|
11
|
|
|
|
|
112
|
|
31
|
11
|
|
|
11
|
|
31645
|
use Moo; |
|
11
|
|
|
|
|
121439
|
|
|
11
|
|
|
|
|
63
|
|
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
|
243
|
my ($self) = @_; |
48
|
141
|
|
|
|
|
472
|
return $self->_meta; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub BUILD |
52
|
|
|
|
|
|
|
{ |
53
|
47
|
|
|
47
|
0
|
8578
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
47
|
|
|
|
|
226
|
require Moo::Role; |
56
|
|
|
|
|
|
|
Moo::Role->apply_roles_to_object( |
57
|
0
|
|
|
|
|
0
|
$self, @{$self->_meta->form_roles} |
58
|
47
|
50
|
|
|
|
75
|
) if @{$self->_meta->form_roles}; |
|
47
|
|
|
|
|
568
|
|
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.20'; |
68
|
11
|
|
|
11
|
|
18358
|
use v5.10; |
|
11
|
|
|
|
|
43
|
|
69
|
11
|
|
|
11
|
|
92
|
use strict; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
343
|
|
70
|
11
|
|
|
11
|
|
119
|
use warnings; |
|
11
|
|
|
|
|
37
|
|
|
11
|
|
|
|
|
404
|
|
71
|
|
|
|
|
|
|
|
72
|
11
|
|
|
11
|
|
70
|
use Types::Standard qw(Str); |
|
11
|
|
|
|
|
49
|
|
|
11
|
|
|
|
|
89
|
|
73
|
|
|
|
|
|
|
|
74
|
11
|
|
|
11
|
|
21146
|
use Form::Tiny::Utils qw(trim create_anon_form_meta); |
|
11
|
|
|
|
|
40
|
|
|
11
|
|
|
|
|
4986
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _build |
77
|
|
|
|
|
|
|
{ |
78
|
54
|
|
|
54
|
|
165
|
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
|
|
|
|
|
3983
|
require Form::Tiny; |
83
|
54
|
|
|
|
|
161
|
my $wanted = Form::Tiny->ft_run_plugins(undef, undef, @{$self->{plugins}}); |
|
54
|
|
|
|
|
295
|
|
84
|
|
|
|
|
|
|
|
85
|
54
|
|
|
|
|
103
|
my $meta = create_anon_form_meta(@{$wanted->{meta_roles}}); |
|
54
|
|
|
|
|
211
|
|
86
|
54
|
|
|
|
|
1001
|
$meta->set_form_roles($wanted->{roles}); |
87
|
54
|
|
|
|
|
1345
|
$meta->bootstrap; |
88
|
|
|
|
|
|
|
|
89
|
54
|
100
|
|
|
|
258
|
if ($args{fields}) { |
90
|
1
|
|
|
|
|
2
|
for my $field_name (keys %{$args{fields}}) { |
|
1
|
|
|
|
|
19
|
|
91
|
|
|
|
|
|
|
$meta->add_field( |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
name => $field_name, |
94
|
1
|
|
|
|
|
3
|
%{$args{fields}{$field_name}}, |
|
1
|
|
|
|
|
9
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
54
|
|
100
|
|
|
92
|
for my $field (@{$args{field_defs} // []}) { |
|
54
|
|
|
|
|
181
|
|
101
|
46
|
|
|
|
|
146
|
$meta->add_field($field); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
47
|
100
|
|
|
|
166
|
if ($args{cleaner}) { |
105
|
1
|
|
|
|
|
5
|
$meta->add_hook(cleanup => $args{cleaner}); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
47
|
100
|
|
|
|
322
|
if ($meta->can('add_filter')) { |
109
|
3
|
|
|
|
|
24
|
$meta->add_global_trim_filter; |
110
|
|
|
|
|
|
|
|
111
|
3
|
|
100
|
|
|
10
|
for my $filter (@{$args{filters} // []}) { |
|
3
|
|
|
|
|
22
|
|
112
|
1
|
|
|
|
|
5
|
$meta->add_filter(@$filter); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
47
|
|
|
|
|
868
|
return Form::Tiny::Inline::Form->new(%args, _meta => $meta); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub create |
120
|
|
|
|
|
|
|
{ |
121
|
54
|
|
|
54
|
|
135
|
my ($self, @plugins) = @_; |
122
|
|
|
|
|
|
|
|
123
|
54
|
|
|
|
|
229
|
@plugins = map { ucfirst lc $_ } @plugins; |
|
7
|
|
|
|
|
78
|
|
124
|
|
|
|
|
|
|
|
125
|
54
|
|
|
|
|
303
|
return bless { |
126
|
|
|
|
|
|
|
plugins => \@plugins |
127
|
|
|
|
|
|
|
}, $self; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub new |
131
|
|
|
|
|
|
|
{ |
132
|
54
|
|
|
54
|
|
140
|
my $self = shift; |
133
|
54
|
|
|
|
|
94
|
my %params; |
134
|
54
|
50
|
33
|
|
|
212
|
if (@_ == 1 && ref $_[0] eq 'HASH') { |
135
|
0
|
|
|
|
|
0
|
%params = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else { |
138
|
54
|
|
|
|
|
164
|
%params = @_; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
54
|
|
|
|
|
221
|
return $self->_build(%params); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |