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