line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Element::Number; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
716
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
77
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use Moose; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'HTML::FormFu::Element::Text'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
after BUILD => sub { |
11
|
|
|
|
|
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$self->deflator('FormatNumber'); |
14
|
|
|
|
|
|
|
$self->filter('FormatNumber'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return; |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub precision { |
20
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
return $self->get_deflator( { type => 'FormatNumber' } )->precision(@_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub trailing_zeroes { |
26
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $self->get_deflator( { type => 'FormatNumber' } ) |
29
|
|
|
|
|
|
|
->trailing_zeroes(@_); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
HTML::FormFu::Element::Number - Number element with formatting |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 VERSION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
version 2.05 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
--- |
49
|
|
|
|
|
|
|
elements: |
50
|
|
|
|
|
|
|
- type: Number |
51
|
|
|
|
|
|
|
locale: de_DE |
52
|
|
|
|
|
|
|
precision: 2 |
53
|
|
|
|
|
|
|
trailing_zeroes: 1 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This element formats numbers according to the current locale. You can set this |
59
|
|
|
|
|
|
|
locale either by setting C<< $form->locale >> or by setting the element's |
60
|
|
|
|
|
|
|
locale. If none of them is set the element uses the system's locale. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 locale |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Set the locale for this element. The format of the number is chosen according |
67
|
|
|
|
|
|
|
to this locale. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 precision |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Set the precision for the number. Defaults to C<2>. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 trailing_zeroes |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
If this is set to C<1> the number has trailing zeroes. Defaults to C<0>. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 CHANGED BEHAVIOUR AS OF VERSION 0.09011 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Previous to version 0.09011, this element generated an input field with |
80
|
|
|
|
|
|
|
C<type="number"> attribute which was not valid xhtml. |
81
|
|
|
|
|
|
|
Neither was the formatted numbers valid html5 - which expects the value to |
82
|
|
|
|
|
|
|
be a floating-point number. |
83
|
|
|
|
|
|
|
This element now generates a C<type="text"> attribute. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SEE ALSO |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L<HTML::FormFu::Deflator::FormatNumber> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<HTML::FormFu::Filter::FormatNumber> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L<HTML::FormFu/locale> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Moritz Onken C< onken at houseofdesign.de > |