| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
811
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
137
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::FormFu::Filter::CopyValue; |
|
4
|
|
|
|
|
|
|
$HTML::FormFu::Filter::CopyValue::VERSION = '2.07'; |
|
5
|
|
|
|
|
|
|
# ABSTRACT: copy the value from another field |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
15
|
use Moose; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
17
|
|
|
8
|
2
|
|
|
2
|
|
14144
|
use MooseX::Attribute::Chained; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
415
|
|
|
9
|
|
|
|
|
|
|
extends 'HTML::FormFu::Filter'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'HTML::FormFu::Role::NestedHashUtils'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has field => ( is => 'rw', traits => ['Chained'] ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub filter { |
|
16
|
1
|
|
|
1
|
0
|
5
|
my ( $self, $value ) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
50
|
33
|
|
|
5
|
return $value |
|
19
|
|
|
|
|
|
|
if ( defined $value && length $value ); |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
35
|
my $field_name = $self->field |
|
22
|
|
|
|
|
|
|
or die "Parameter 'field' is not defined."; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
4
|
my $parent = $self->parent |
|
25
|
|
|
|
|
|
|
or die "Can't determine my parent."; |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
4
|
my $field_value |
|
28
|
|
|
|
|
|
|
= $self->get_nested_hash_value( $parent->form->input, $field_name, ); |
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
4
|
return $field_value; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding UTF-8 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
HTML::FormFu::Filter::CopyValue - copy the value from another field |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
version 2.07 |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
elements: |
|
54
|
|
|
|
|
|
|
- type: Text |
|
55
|
|
|
|
|
|
|
name: username |
|
56
|
|
|
|
|
|
|
- type: Text |
|
57
|
|
|
|
|
|
|
name: nickname |
|
58
|
|
|
|
|
|
|
filters: |
|
59
|
|
|
|
|
|
|
- type: CopyValue |
|
60
|
|
|
|
|
|
|
field: username |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Filter copying the value of another field if the original value of this field |
|
65
|
|
|
|
|
|
|
is empty. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 CAVEATS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If the original field contains an invalid value (a value that will be |
|
70
|
|
|
|
|
|
|
constrained through a constraint) that invalid value will be copied to this |
|
71
|
|
|
|
|
|
|
field (the field with the CopyValue filter). So, the user has to change two |
|
72
|
|
|
|
|
|
|
fields, or you can remove the invalid value in a custom constraint. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Mario Minati, C<mario.minati@googlemail.com> |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
81
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Carl Franks <cpan@fireartist.com> |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Carl Franks. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
92
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |