line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Shakan::Field::Choice; |
2
|
23
|
|
|
23
|
|
151
|
use strict; |
|
23
|
|
|
|
|
50
|
|
|
23
|
|
|
|
|
535
|
|
3
|
23
|
|
|
23
|
|
103
|
use warnings; |
|
23
|
|
|
|
|
47
|
|
|
23
|
|
|
|
|
725
|
|
4
|
|
|
|
|
|
|
|
5
|
23
|
|
|
23
|
|
118
|
use List::Util 1.32 qw/pairkeys/; |
|
23
|
|
|
|
|
477
|
|
|
23
|
|
|
|
|
2110
|
|
6
|
|
|
|
|
|
|
|
7
|
23
|
|
|
23
|
|
130
|
use Mouse; |
|
23
|
|
|
|
|
45
|
|
|
23
|
|
|
|
|
119
|
|
8
|
|
|
|
|
|
|
extends 'HTML::Shakan::Field'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has '+widget' => ( |
11
|
|
|
|
|
|
|
default => 'select' |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has choices => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => 'ArrayRef', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'id_tmpl' => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => 'Str', |
23
|
|
|
|
|
|
|
default => 'id_%s_%s', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has item_label_class => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => 'Str', |
29
|
|
|
|
|
|
|
predicate => 'has_item_label_class', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
override 'get_constraints' => sub { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
my ($name, $constraints) = super(); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return ( |
37
|
|
|
|
|
|
|
$name => [ |
38
|
|
|
|
|
|
|
@$constraints, |
39
|
|
|
|
|
|
|
['CHOICE' => [ pairkeys @{$self->choices} ] ] |
40
|
|
|
|
|
|
|
] |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
23
|
|
|
23
|
|
9446
|
no Mouse; |
|
23
|
|
|
|
|
54
|
|
|
23
|
|
|
|
|
94
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
HTML::Shakan::Field::Choice - choice field |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
use HTML::Shakan::Field::Choice; |
55
|
|
|
|
|
|
|
HTML::Shakan::Field::Choice->new( |
56
|
|
|
|
|
|
|
name => 'pref', |
57
|
|
|
|
|
|
|
choices => [ |
58
|
|
|
|
|
|
|
#value=> label |
59
|
|
|
|
|
|
|
tokyo => 'tokyo', |
60
|
|
|
|
|
|
|
osaka => 'osaka', |
61
|
|
|
|
|
|
|
kyoto => 'kyoto', |
62
|
|
|
|
|
|
|
], |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# or shortcut |
66
|
|
|
|
|
|
|
use HTML::Shakan::Fields; |
67
|
|
|
|
|
|
|
ChoiceField( |
68
|
|
|
|
|
|
|
name => 'pref', |
69
|
|
|
|
|
|
|
choices => [ |
70
|
|
|
|
|
|
|
tokyo => 'tokyo', |
71
|
|
|
|
|
|
|
osaka => 'osaka', |
72
|
|
|
|
|
|
|
kyoto => 'kyoto', |
73
|
|
|
|
|
|
|
], |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# if you want radio button |
77
|
|
|
|
|
|
|
ChoiceField( |
78
|
|
|
|
|
|
|
name => 'pref', |
79
|
|
|
|
|
|
|
choices => [ |
80
|
|
|
|
|
|
|
tokyo => 'tokyo', |
81
|
|
|
|
|
|
|
osaka => 'osaka', |
82
|
|
|
|
|
|
|
kyoto => 'kyoto', |
83
|
|
|
|
|
|
|
], |
84
|
|
|
|
|
|
|
widget => 'radio', |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# if you want checkbox |
88
|
|
|
|
|
|
|
ChoiceField( |
89
|
|
|
|
|
|
|
name => 'pref', |
90
|
|
|
|
|
|
|
choices => [ |
91
|
|
|
|
|
|
|
tokyo => 'tokyo', |
92
|
|
|
|
|
|
|
osaka => 'osaka', |
93
|
|
|
|
|
|
|
kyoto => 'kyoto', |
94
|
|
|
|
|
|
|
], |
95
|
|
|
|
|
|
|
widget => 'checkbox', |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 DESCRIPTION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Choice field implementation. This field may show in HTML as C<< <select></select> >> tag. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 base class |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
HTML::Shakan::Field |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<HTML::Shakan> |