line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Plugin::Diva::Adapter; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
37
|
use v5.10; |
|
4
|
|
|
|
|
10
|
|
4
|
4
|
|
|
4
|
|
15
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
57
|
|
5
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
154
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
20
|
use parent 'Form::Diva'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _ftpd_generate_errors |
12
|
|
|
|
|
|
|
{ |
13
|
36
|
|
|
36
|
|
102
|
my ($self, $errors_arr) = @_; |
14
|
36
|
|
|
|
|
45
|
my $error_class = $self->{error_class}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return join '', map { |
17
|
10
|
|
|
|
|
39
|
qq| $_ | |
18
|
36
|
|
|
|
|
41
|
} @{$errors_arr}; |
|
36
|
|
|
|
|
77
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _ftpd_tweak |
22
|
|
|
|
|
|
|
{ |
23
|
19
|
|
|
19
|
|
30
|
my ($self, $generated) = @_; |
24
|
|
|
|
|
|
|
|
25
|
19
|
|
|
|
|
55
|
my $errors = $self->{form_instance}->errors_hash; |
26
|
19
|
|
|
|
|
676
|
for my $field (@{$generated}) { |
|
19
|
|
|
|
|
31
|
|
27
|
35
|
|
|
|
|
46
|
my $extra_data = $field->{comment}; |
28
|
|
|
|
|
|
|
|
29
|
35
|
|
|
|
|
77
|
$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
|
|
|
160
|
|| (exists $extra_data->{label} && !defined $extra_data->{label}); |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
19
|
|
|
|
|
75
|
return $generated; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub generate |
41
|
|
|
|
|
|
|
{ |
42
|
13
|
|
|
13
|
1
|
6090
|
my $self = shift; |
43
|
13
|
|
100
|
|
|
83
|
my $generated = $self->SUPER::generate(@_ || $self->{form_instance}->input); |
44
|
|
|
|
|
|
|
|
45
|
13
|
|
|
|
|
2210
|
return $self->_ftpd_tweak($generated); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub prefill |
49
|
|
|
|
|
|
|
{ |
50
|
6
|
|
|
6
|
1
|
7721
|
my $self = shift; |
51
|
6
|
|
66
|
|
|
58
|
my $generated = $self->SUPER::prefill(@_ || $self->{form_instance}->input); |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
34
|
return $self->_ftpd_tweak($generated); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub hidden |
57
|
|
|
|
|
|
|
{ |
58
|
4
|
|
|
4
|
1
|
56
|
my $self = shift; |
59
|
4
|
|
66
|
|
|
31
|
return $self->SUPER::hidden(@_ || $self->{form_instance}->input); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub datavalues |
63
|
|
|
|
|
|
|
{ |
64
|
2
|
|
|
2
|
1
|
3975
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# check if input has references or undefs |
67
|
2
|
50
|
|
|
|
7
|
if (@_ == grep { defined $_ && !ref $_ } @_) { |
|
1
|
50
|
|
|
|
9
|
|
68
|
2
|
|
|
|
|
20
|
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
|
1411
|
my ($self) = @_; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
4
|
$self->_ftpd_generate_errors($self->{form_instance}->errors_hash->{''}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |