line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Field::IntRange; |
2
|
|
|
|
|
|
|
# ABSTRACT: integer range in select list |
3
|
|
|
|
|
|
|
$HTML::FormHandler::Field::IntRange::VERSION = '0.40067'; |
4
|
3
|
|
|
3
|
|
2107
|
use Moose; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
extends 'HTML::FormHandler::Field::Select'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'label_format' => ( isa => 'Str', is => 'rw', default => '%d' ); |
8
|
|
|
|
|
|
|
has '+range_start' => ( default => 1 ); |
9
|
|
|
|
|
|
|
has '+range_end' => ( default => 10 ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub build_options { |
12
|
10
|
|
|
10
|
0
|
15
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
10
|
|
|
|
|
284
|
my $start = $self->range_start; |
15
|
10
|
|
|
|
|
274
|
my $end = $self->range_end; |
16
|
|
|
|
|
|
|
|
17
|
10
|
|
|
|
|
27
|
for ( $start, $end ) { |
18
|
20
|
50
|
|
|
|
44
|
die "Both range_start and range_end must be defined" unless defined $_; |
19
|
20
|
50
|
|
|
|
93
|
die "Integer ranges must be integers" unless /^\d+$/; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
10
|
50
|
|
|
|
29
|
die "range_start must be less than range_end" unless $start < $end; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
50
|
|
|
303
|
my $format = $self->label_format || die 'IntRange needs label_format'; |
25
|
|
|
|
|
|
|
|
26
|
10
|
|
|
|
|
250
|
return [ map { { value => $_, label => sprintf( $format, $_ ) } } |
|
258
|
|
|
|
|
695
|
|
27
|
|
|
|
|
|
|
$self->range_start .. $self->range_end ]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
32
|
3
|
|
|
3
|
|
13549
|
use namespace::autoclean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
25
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=encoding UTF-8 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
HTML::FormHandler::Field::IntRange - integer range in select list |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 VERSION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
version 0.40067 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This field generates a select list of numbers from 1 to 10. Override the |
52
|
|
|
|
|
|
|
range_start and range_end for a select list with a different range. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has_field 'age' => ( type => 'IntRange', |
55
|
|
|
|
|
|
|
range_start => 0, range_end => 100 ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Widget type is 'select'. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHOR |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Gerda Shank. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
68
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |