line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Filter::CompoundSprintf; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
491
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
126
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
13
|
use Moose; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
17
|
|
7
|
3
|
|
|
3
|
|
12628
|
use MooseX::Attribute::FormFuChained; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
116
|
|
8
|
|
|
|
|
|
|
extends 'HTML::FormFu::Filter'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'HTML::FormFu::Role::Filter::Compound'; |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
13
|
use HTML::FormFu::Constants qw( $EMPTY_STR ); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
321
|
|
13
|
3
|
|
|
3
|
|
13
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
474
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has sprintf => ( is => 'rw', traits => ['FormFuChained'] ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub filter { |
18
|
2
|
|
|
2
|
0
|
2
|
my ( $self, $value ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2
|
50
|
33
|
|
|
23
|
return if !defined $value || $value eq $EMPTY_STR; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
79
|
my $sprintf = $self->sprintf; |
23
|
|
|
|
|
|
|
|
24
|
2
|
50
|
|
|
|
8
|
croak 'sprintf pattern required' if !defined $sprintf; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
11
|
my @values = $self->_get_values($value); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
22
|
$value = CORE::sprintf( $sprintf, @values ); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
11
|
return $value; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
HTML::FormFu::Filter::CompoundSprintf - CompoundSprintf filter |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
version 2.05 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
--- |
50
|
|
|
|
|
|
|
element: |
51
|
|
|
|
|
|
|
- type: Multi |
52
|
|
|
|
|
|
|
name: date |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
elements: |
55
|
|
|
|
|
|
|
- name: day |
56
|
|
|
|
|
|
|
- name: month |
57
|
|
|
|
|
|
|
- name: year |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
filter: |
60
|
|
|
|
|
|
|
- type: CompoundSprintf |
61
|
|
|
|
|
|
|
sprintf: '%02d-%02d-%04d' |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# get the compound-value |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $date = $form->param_value('date'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
For use with a L<HTML::FormFu::Element::Multi> group of fields. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Uses a sprintf pattern to join the input from several fields into a single |
72
|
|
|
|
|
|
|
value. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 sprintf |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Arguments: $string |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
C<sprintf> pattern used to join the individually submitted parts. |
81
|
|
|
|
|
|
|
The pattern is passed to the perl-core C<sprintf> function. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 field_order |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Inherited. See L<HTML::FormFu::Filter::_Compound/field_order> for details. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
--- |
88
|
|
|
|
|
|
|
element: |
89
|
|
|
|
|
|
|
- type: Multi |
90
|
|
|
|
|
|
|
name: date |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
elements: |
93
|
|
|
|
|
|
|
- name: month |
94
|
|
|
|
|
|
|
- name: day |
95
|
|
|
|
|
|
|
- name year |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
filter: |
98
|
|
|
|
|
|
|
- type: CompoundSprintf |
99
|
|
|
|
|
|
|
field_order: |
100
|
|
|
|
|
|
|
- day |
101
|
|
|
|
|
|
|
- month |
102
|
|
|
|
|
|
|
- year |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
111
|
|
|
|
|
|
|
the same terms as Perl itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |