line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Field::TextCSV; |
2
|
|
|
|
|
|
|
# ABSTRACT: CSV Text field from multiple |
3
|
|
|
|
|
|
|
$HTML::FormHandler::Field::TextCSV::VERSION = '0.40067'; |
4
|
1
|
|
|
1
|
|
803
|
use HTML::FormHandler::Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
extends 'HTML::FormHandler::Field::Text'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has '+deflate_method' => ( default => sub { \&textcsv_deflate } ); |
9
|
|
|
|
|
|
|
has '+inflate_method' => ( default => sub { \&textcsv_inflate } ); |
10
|
|
|
|
|
|
|
has 'multiple' => ( isa => 'Bool', is => 'rw', default => '0' ); |
11
|
0
|
|
|
0
|
0
|
0
|
sub build_value_when_empty { [] } |
12
|
|
|
|
|
|
|
sub _inner_validate_field { |
13
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
14
|
1
|
|
|
|
|
4
|
my $value = $self->value; |
15
|
1
|
50
|
|
|
|
4
|
return unless $value; |
16
|
1
|
50
|
|
|
|
5
|
if ( ref $value ne 'ARRAY' ) { |
17
|
0
|
|
|
|
|
0
|
$value = [$value]; |
18
|
0
|
|
|
|
|
0
|
$self->_set_value($value); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub textcsv_deflate { |
23
|
6
|
|
|
6
|
0
|
6
|
my ( $self, $value ) = @_; |
24
|
6
|
50
|
33
|
|
|
29
|
if( defined $value && length $value ) { |
25
|
6
|
50
|
|
|
|
14
|
my $value = ref $value eq 'ARRAY' ? $value : [$value]; |
26
|
6
|
|
|
|
|
14
|
my $new_value = join(',', @$value); |
27
|
6
|
|
|
|
|
15
|
return $new_value; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
0
|
return $value; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub textcsv_inflate { |
33
|
1
|
|
|
1
|
0
|
2
|
my ( $self, $value ) = @_; |
34
|
1
|
50
|
33
|
|
|
7
|
if ( defined $value && length $value ) { |
35
|
1
|
|
|
|
|
12
|
my @values = split(/,/, $value); |
36
|
1
|
|
|
|
|
5
|
return \@values; |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
return $value; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding UTF-8 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
HTML::FormHandler::Field::TextCSV - CSV Text field from multiple |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
version 0.40067 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A text field that takes multiple values from a database and converts |
61
|
|
|
|
|
|
|
them to comma-separated values. This is intended for javascript fields |
62
|
|
|
|
|
|
|
that require that, such as 'select2'. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 NAME |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
HTML::FormHandler::Field::TextCSV |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Gerda Shank. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
77
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |