| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
520
|
use v5.10; |
|
|
1
|
|
|
|
|
4
|
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# NOTE: this way of building the form is not covered by backwards compatibility |
|
6
|
|
|
|
|
|
|
# policy. Use for educational purposes only! |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
{ |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package MetaForm; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Moo for easy role mixing and a constructor |
|
13
|
1
|
|
|
1
|
|
580
|
use Moo; |
|
|
1
|
|
|
|
|
11517
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# gives us create_form_meta function |
|
16
|
1
|
|
|
1
|
|
1949
|
use Form::Tiny::Utils qw(:meta_handlers); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
265
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# meta roles go into the qw() |
|
19
|
|
|
|
|
|
|
# class roles goes into set_form_roles method call |
|
20
|
|
|
|
|
|
|
my $meta = create_form_meta(__PACKAGE__, qw()) |
|
21
|
|
|
|
|
|
|
->set_form_roles(['Form::Tiny::Form']); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# if you would like to add superclasses, this is the place to do so |
|
24
|
|
|
|
|
|
|
# extends '...'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# you could use $meta directly, but you would first have to call ->bootstrap on it |
|
27
|
|
|
|
|
|
|
# the from_meta method will automatically find the proper meta for this package and |
|
28
|
|
|
|
|
|
|
# call that method |
|
29
|
|
|
|
|
|
|
__PACKAGE__->form_meta->add_field( |
|
30
|
|
|
|
|
|
|
'field-name' => ( |
|
31
|
|
|
|
|
|
|
required => 1, |
|
32
|
|
|
|
|
|
|
) |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $form = MetaForm->new( |
|
39
|
|
|
|
|
|
|
input => { |
|
40
|
|
|
|
|
|
|
'field-name' => 42, |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# just for testing |
|
45
|
|
|
|
|
|
|
$form; |
|
46
|
|
|
|
|
|
|
|