line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Inline; |
2
|
|
|
|
|
|
|
$Form::Tiny::Inline::VERSION = '2.19'; |
3
|
11
|
|
|
11
|
|
945769
|
use v5.10; |
|
11
|
|
|
|
|
153
|
|
4
|
11
|
|
|
11
|
|
77
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
289
|
|
5
|
11
|
|
|
11
|
|
61
|
use warnings; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
1427
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub is |
8
|
|
|
|
|
|
|
{ |
9
|
6
|
|
|
6
|
1
|
3928
|
my ($class, @roles) = @_; |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
|
|
43
|
return Form::Tiny::Inline::Builder->create(@roles); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
48
|
|
|
48
|
1
|
18472
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
48
|
|
|
|
|
171
|
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.19'; |
26
|
11
|
|
|
11
|
|
122
|
use v5.10; |
|
11
|
|
|
|
|
37
|
|
27
|
11
|
|
|
11
|
|
68
|
use strict; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
281
|
|
28
|
11
|
|
|
11
|
|
57
|
use warnings; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
429
|
|
29
|
|
|
|
|
|
|
|
30
|
11
|
|
|
11
|
|
7336
|
use Types::Standard qw(InstanceOf); |
|
11
|
|
|
|
|
1093208
|
|
|
11
|
|
|
|
|
122
|
|
31
|
11
|
|
|
11
|
|
31921
|
use Moo; |
|
11
|
|
|
|
|
122844
|
|
|
11
|
|
|
|
|
57
|
|
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
|
244
|
my ($self) = @_; |
48
|
141
|
|
|
|
|
489
|
return $self->_meta; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub BUILD |
52
|
|
|
|
|
|
|
{ |
53
|
47
|
|
|
47
|
0
|
9243
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
47
|
|
|
|
|
235
|
require Moo::Role; |
56
|
|
|
|
|
|
|
Moo::Role->apply_roles_to_object( |
57
|
0
|
|
|
|
|
0
|
$self, @{$self->_meta->form_roles} |
58
|
47
|
50
|
|
|
|
95
|
) if @{$self->_meta->form_roles}; |
|
47
|
|
|
|
|
574
|
|
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.19'; |
68
|
11
|
|
|
11
|
|
18517
|
use v5.10; |
|
11
|
|
|
|
|
45
|
|
69
|
11
|
|
|
11
|
|
83
|
use strict; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
282
|
|
70
|
11
|
|
|
11
|
|
98
|
use warnings; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
387
|
|
71
|
|
|
|
|
|
|
|
72
|
11
|
|
|
11
|
|
102
|
use Types::Standard qw(Str); |
|
11
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
120
|
|
73
|
|
|
|
|
|
|
|
74
|
11
|
|
|
11
|
|
21467
|
use Form::Tiny::Utils qw(trim create_anon_form_meta); |
|
11
|
|
|
|
|
37
|
|
|
11
|
|
|
|
|
4922
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _build |
77
|
|
|
|
|
|
|
{ |
78
|
54
|
|
|
54
|
|
150
|
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
|
|
|
|
|
3679
|
require Form::Tiny; |
83
|
54
|
|
|
|
|
131
|
my $wanted = Form::Tiny->ft_run_plugins(undef, undef, @{$self->{plugins}}); |
|
54
|
|
|
|
|
286
|
|
84
|
|
|
|
|
|
|
|
85
|
54
|
|
|
|
|
89
|
my $meta = create_anon_form_meta(@{$wanted->{meta_roles}}); |
|
54
|
|
|
|
|
185
|
|
86
|
54
|
|
|
|
|
1023
|
$meta->set_form_roles($wanted->{roles}); |
87
|
54
|
|
|
|
|
1323
|
$meta->bootstrap; |
88
|
|
|
|
|
|
|
|
89
|
54
|
100
|
|
|
|
290
|
if ($args{fields}) { |
90
|
1
|
|
|
|
|
5
|
for my $field_name (keys %{$args{fields}}) { |
|
1
|
|
|
|
|
11
|
|
91
|
|
|
|
|
|
|
$meta->add_field( |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
name => $field_name, |
94
|
1
|
|
|
|
|
4
|
%{$args{fields}{$field_name}}, |
|
1
|
|
|
|
|
8
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
54
|
|
100
|
|
|
112
|
for my $field (@{$args{field_defs} // []}) { |
|
54
|
|
|
|
|
194
|
|
101
|
46
|
|
|
|
|
160
|
$meta->add_field($field); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
47
|
100
|
|
|
|
139
|
if ($args{cleaner}) { |
105
|
1
|
|
|
|
|
5
|
$meta->add_hook(cleanup => $args{cleaner}); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
47
|
100
|
|
|
|
328
|
if ($meta->can('add_filter')) { |
109
|
3
|
|
|
|
|
24
|
$meta->add_global_trim_filter; |
110
|
|
|
|
|
|
|
|
111
|
3
|
|
100
|
|
|
22
|
for my $filter (@{$args{filters} // []}) { |
|
3
|
|
|
|
|
40
|
|
112
|
1
|
|
|
|
|
5
|
$meta->add_filter(@$filter); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
47
|
|
|
|
|
848
|
return Form::Tiny::Inline::Form->new(%args, _meta => $meta); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub create |
120
|
|
|
|
|
|
|
{ |
121
|
54
|
|
|
54
|
|
120
|
my ($self, @plugins) = @_; |
122
|
|
|
|
|
|
|
|
123
|
54
|
|
|
|
|
230
|
@plugins = map { ucfirst lc $_ } @plugins; |
|
7
|
|
|
|
|
70
|
|
124
|
|
|
|
|
|
|
|
125
|
54
|
|
|
|
|
295
|
return bless { |
126
|
|
|
|
|
|
|
plugins => \@plugins |
127
|
|
|
|
|
|
|
}, $self; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub new |
131
|
|
|
|
|
|
|
{ |
132
|
54
|
|
|
54
|
|
140
|
my $self = shift; |
133
|
54
|
|
|
|
|
81
|
my %params; |
134
|
54
|
50
|
33
|
|
|
225
|
if (@_ == 1 && ref $_[0] eq 'HASH') { |
135
|
0
|
|
|
|
|
0
|
%params = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else { |
138
|
54
|
|
|
|
|
167
|
%params = @_; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
54
|
|
|
|
|
236
|
return $self->_build(%params); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |