| 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.40068'; |
|
4
|
3
|
|
|
3
|
|
2514
|
use Moose; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
24
|
|
|
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
|
24
|
my $self = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
10
|
|
|
|
|
328
|
my $start = $self->range_start; |
|
15
|
10
|
|
|
|
|
364
|
my $end = $self->range_end; |
|
16
|
|
|
|
|
|
|
|
|
17
|
10
|
|
|
|
|
38
|
for ( $start, $end ) { |
|
18
|
20
|
50
|
|
|
|
57
|
die "Both range_start and range_end must be defined" unless defined $_; |
|
19
|
20
|
50
|
|
|
|
106
|
die "Integer ranges must be integers" unless /^\d+$/; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
10
|
50
|
|
|
|
47
|
die "range_start must be less than range_end" unless $start < $end; |
|
23
|
|
|
|
|
|
|
|
|
24
|
10
|
|
50
|
|
|
321
|
my $format = $self->label_format || die 'IntRange needs label_format'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
10
|
|
|
|
|
280
|
return [ map { { value => $_, label => sprintf( $format, $_ ) } } |
|
|
258
|
|
|
|
|
977
|
|
|
27
|
|
|
|
|
|
|
$self->range_start .. $self->range_end ]; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
32
|
3
|
|
|
3
|
|
20153
|
use namespace::autoclean; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
38
|
|
|
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.40068 |
|
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) 2017 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 |