| 1 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | |||
| 3 | package HTML::FormFu::Element::Number; | ||
| 4 | 2 | $HTML::FormFu::Element::Number::VERSION = '2.06'; | |
| 5 | # ABSTRACT: Number element with formatting | ||
| 6 | |||
| 7 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 2 | extends 'HTML::FormFu::Element::Text'; | |
| 10 | |||
| 11 | after BUILD => sub { | ||
| 12 | 1 | ▶ | my $self = shift; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 1 | $self->deflator('FormatNumber'); | |
| 15 | 1 | $self->filter('FormatNumber'); | |
| 16 | |||
| 17 | 1 | return; | |
| 18 | 2 | }; | |
| 19 | |||
| 20 | sub precision { | ||
| 21 | 0 | ▶ | my $self = shift; |
|
Subroutine
precision: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 22 | |||
| 23 | 0 | return $self->get_deflator( { type => 'FormatNumber' } )->precision(@_); | |
| 24 | } | ||
| 25 | |||
| 26 | sub trailing_zeroes { | ||
| 27 | 0 | ▶ | my $self = shift; |
|
Subroutine
trailing_zeroes: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 28 | |||
| 29 | 0 | return $self->get_deflator( { type => 'FormatNumber' } ) | |
| 30 | ->trailing_zeroes(@_); | ||
| 31 | } | ||
| 32 | |||
| 33 | 2 | __PACKAGE__->meta->make_immutable; | |
| 34 | |||
| 35 | 2 | 1; | |
| 36 | |||
| 37 | __END__ | ||
| 38 | |||
| 39 | =pod | ||
| 40 | |||
| 41 | =encoding UTF-8 | ||
| 42 | |||
| 43 | =head1 NAME | ||
| 44 | |||
| 45 | HTML::FormFu::Element::Number - Number element with formatting | ||
| 46 | |||
| 47 | =head1 VERSION | ||
| 48 | |||
| 49 | version 2.06 | ||
| 50 | |||
| 51 | =head1 SYNOPSIS | ||
| 52 | |||
| 53 | --- | ||
| 54 | elements: | ||
| 55 | - type: Number | ||
| 56 | locale: de_DE | ||
| 57 | precision: 2 | ||
| 58 | trailing_zeroes: 1 | ||
| 59 | |||
| 60 | =head1 DESCRIPTION | ||
| 61 | |||
| 62 | This element formats numbers according to the current locale. You can set this | ||
| 63 | locale either by setting C<< $form->locale >> or by setting the element's | ||
| 64 | locale. If none of them is set the element uses the system's locale. | ||
| 65 | |||
| 66 | =head1 METHODS | ||
| 67 | |||
| 68 | =head2 locale | ||
| 69 | |||
| 70 | Set the locale for this element. The format of the number is chosen according | ||
| 71 | to this locale. | ||
| 72 | |||
| 73 | =head2 precision | ||
| 74 | |||
| 75 | Set the precision for the number. Defaults to C<2>. | ||
| 76 | |||
| 77 | =head2 trailing_zeroes | ||
| 78 | |||
| 79 | If this is set to C<1> the number has trailing zeroes. Defaults to C<0>. | ||
| 80 | |||
| 81 | =head2 CHANGED BEHAVIOUR AS OF VERSION 0.09011 | ||
| 82 | |||
| 83 | Previous to version 0.09011, this element generated an input field with | ||
| 84 | C<type="number"> attribute which was not valid xhtml. | ||
| 85 | Neither was the formatted numbers valid html5 - which expects the value to | ||
| 86 | be a floating-point number. | ||
| 87 | This element now generates a C<type="text"> attribute. | ||
| 88 | |||
| 89 | =head1 SEE ALSO | ||
| 90 | |||
| 91 | L<HTML::FormFu::Deflator::FormatNumber> | ||
| 92 | |||
| 93 | L<HTML::FormFu::Filter::FormatNumber> | ||
| 94 | |||
| 95 | L<HTML::FormFu/locale> | ||
| 96 | |||
| 97 | =head1 AUTHOR | ||
| 98 | |||
| 99 | Moritz Onken C< onken at houseofdesign.de > | ||
| 100 | |||
| 101 | =head1 AUTHOR | ||
| 102 | |||
| 103 | Carl Franks <cpan@fireartist.com> | ||
| 104 | |||
| 105 | =head1 COPYRIGHT AND LICENSE | ||
| 106 | |||
| 107 | This software is copyright (c) 2018 by Carl Franks. | ||
| 108 | |||
| 109 | This is free software; you can redistribute it and/or modify it under | ||
| 110 | the same terms as the Perl 5 programming language system itself. | ||
| 111 | |||
| 112 | =cut | ||