line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Plugin::Diva::Adapter; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
59
|
use v5.10; |
|
4
|
|
|
|
|
15
|
|
4
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
89
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
218
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
27
|
use parent 'Form::Diva'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
30
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _ftpd_generate_errors |
12
|
|
|
|
|
|
|
{ |
13
|
36
|
|
|
36
|
|
133
|
my ($self, $errors_arr) = @_; |
14
|
36
|
|
|
|
|
58
|
my $error_class = $self->{error_class}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return join '', map { |
17
|
10
|
|
|
|
|
55
|
qq| $_ | |
18
|
36
|
|
|
|
|
63
|
} @{$errors_arr}; |
|
36
|
|
|
|
|
100
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _ftpd_tweak |
22
|
|
|
|
|
|
|
{ |
23
|
19
|
|
|
19
|
|
41
|
my ($self, $generated) = @_; |
24
|
|
|
|
|
|
|
|
25
|
19
|
|
|
|
|
68
|
my $errors = $self->{form_instance}->errors_hash; |
26
|
19
|
|
|
|
|
811
|
for my $field (@{$generated}) { |
|
19
|
|
|
|
|
39
|
|
27
|
35
|
|
|
|
|
92
|
my $extra_data = $field->{comment}; |
28
|
|
|
|
|
|
|
|
29
|
35
|
|
|
|
|
110
|
$field->{errors} = $self->_ftpd_generate_errors($errors->{$extra_data->{name}}); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# TODO: https://github.com/brainbuz/form-diva/issues/6 |
32
|
|
|
|
|
|
|
$field->{label} = '' |
33
|
|
|
|
|
|
|
if (exists $extra_data->{l} && !defined $extra_data->{l}) |
34
|
35
|
100
|
66
|
|
|
205
|
|| (exists $extra_data->{label} && !defined $extra_data->{label}); |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
19
|
|
|
|
|
103
|
return $generated; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub generate |
41
|
|
|
|
|
|
|
{ |
42
|
13
|
|
|
13
|
1
|
9425
|
my $self = shift; |
43
|
13
|
|
100
|
|
|
99
|
my $generated = $self->SUPER::generate(@_ || $self->{form_instance}->input); |
44
|
|
|
|
|
|
|
|
45
|
13
|
|
|
|
|
2716
|
return $self->_ftpd_tweak($generated); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub prefill |
49
|
|
|
|
|
|
|
{ |
50
|
6
|
|
|
6
|
1
|
10077
|
my $self = shift; |
51
|
6
|
|
66
|
|
|
74
|
my $generated = $self->SUPER::prefill(@_ || $self->{form_instance}->input); |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
46
|
return $self->_ftpd_tweak($generated); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub hidden |
57
|
|
|
|
|
|
|
{ |
58
|
4
|
|
|
4
|
1
|
73
|
my $self = shift; |
59
|
4
|
|
66
|
|
|
37
|
return $self->SUPER::hidden(@_ || $self->{form_instance}->input); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub datavalues |
63
|
|
|
|
|
|
|
{ |
64
|
2
|
|
|
2
|
1
|
4444
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# check if input has references or undefs |
67
|
2
|
50
|
|
|
|
9
|
if (@_ == grep { defined $_ && !ref $_ } @_) { |
|
1
|
50
|
|
|
|
14
|
|
68
|
2
|
|
|
|
|
17
|
return $self->SUPER::datavalues($self->{form_instance}->input, @_); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
0
|
return $self->SUPER::datavalues(@_); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub form_errors |
76
|
|
|
|
|
|
|
{ |
77
|
1
|
|
|
1
|
0
|
1952
|
my ($self) = @_; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
6
|
$self->_ftpd_generate_errors($self->{form_instance}->errors_hash->{''}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |