| 1 | package HTML::FormHandler::Fields; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: internal role for form and compound fields | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 147 | $HTML::FormHandler::Fields::VERSION = '0.410002'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | 147 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 147 | ▶ | use HTML::FormHandler::TraitFor::Types; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | has 'fields' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 9 | traits => ['Array'], | ||||||||||||||||||||||||||||||||||||||||||
| 10 | isa => 'ArrayRef[HTML::FormHandler::Field]', | ||||||||||||||||||||||||||||||||||||||||||
| 11 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 409 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 147 | auto_deref => 1, | |||||||||||||||||||||||||||||||||||||||||
| 14 | handles => { | ||||||||||||||||||||||||||||||||||||||||||
| 15 | all_fields => 'elements', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | clear_fields => 'clear', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | add_field => 'push', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | push_field => 'push', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | num_fields => 'count', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | has_fields => 'count', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | set_field_at => 'set', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | _pop_field => 'pop', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # This is for updates applied via roles or compound field classes; allows doing | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # both updates on the process call and updates from class applied roles | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 147 | has 'update_subfields' => ( is => 'rw', isa => 'HashRef', builder => 'build_update_subfields', | |||||||||||||||||||||||||||||||||||||||||
| 28 | traits => ['Hash'], handles => { clear_update_subfields => 'clear', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | has_update_subfields => 'count' } ); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 383 | ▶ | sub build_update_subfields {{}} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_update_subfields: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | # used to transfer tags to fields from form and compound fields | ||||||||||||||||||||||||||||||||||||||||||
| 33 | has 'widget_tags' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | traits => ['Hash'], | ||||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 408 | ▶ | default => sub {{}}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 147 | handles => { | |||||||||||||||||||||||||||||||||||||||||
| 39 | has_widget_tags => 'count' | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # compatibility wrappers for result errors | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 14 | ▶ | sub error_fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_fields: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 14 | return map { $_->field_def } @{ $self->result->error_results }; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 20 | ▶ | sub has_error_fields { shift->result->has_error_results } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_error_fields: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub add_error_field { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_error_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my ( $self, $field ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->result->add_error_result( $field->result ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | ▶ | sub num_error_fields { shift->result->num_error_results } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num_error_fields: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 147 | has 'field_name_space' => ( | |||||||||||||||||||||||||||||||||||||||||
| 57 | isa => 'HFH::ArrayRefStr', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | traits => ['Array'], | ||||||||||||||||||||||||||||||||||||||||||
| 60 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | default => '', | ||||||||||||||||||||||||||||||||||||||||||
| 62 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | handles => { | ||||||||||||||||||||||||||||||||||||||||||
| 64 | add_field_name_space => 'push', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1106 | ▶ | sub field_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field_index: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1106 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 1106 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 1106 | for my $field ( $self->all_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 72 | 2065 | ▶ | return $index if $field->name eq $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 2051 | $index++; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 1092 | return; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 11 | ▶ | sub subfield { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfield: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 11 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 11 | return $self->field($name, undef, $self); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 864 | ▶ | sub field { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field: called CC=13 SCAR=26.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 864 | my ( $self, $name, $die, $f ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 864 | my $index; | |||||||||||||||||||||||||||||||||||||||||
| 87 | # if this is a full_name for a compound field | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # walk through the fields to get to it | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 864 | ▶ | return undef unless ( defined $name ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 864 | ▶ | if( $self->form && $self == $self->form && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->form and $self == $self->form and exists $self->index->{$name}
$self->form and $self == $self->form
MC/DC66%2/3
$self->form and $self == $self->form and exists $self->index->{$name}
$self->form
$self == $self->form
exists $self->index->{$name}
Truth table75%3/4
A and B and C
A= $self->formB= $self == $self->formC= exists $self->index->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | exists $self->index->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 757 | return $self->index->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 107 | ▶ | if ( $name =~ /\./ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 12 | my @names = split /\./, $name; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 12 | ▶ | $f ||= $self->form || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$f ||= $self->form || $self
$self->form || $self
MC/DC0%0/3
$f ||= $self->form || $self
$f
$self->form
$self
Truth table0%0/4
A ||= B || C
A= $fB= $self->formC= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | foreach my $fname (@names) { | |||||||||||||||||||||||||||||||||||||||||
| 98 | 30 | $f = $f->field($fname); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 30 | ▶ | return unless $f; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 12 | return $f; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | else # not a compound name | ||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 95 | for my $field ( $self->all_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 106 | 135 | ▶ | return $field if ( $field->name eq $name ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | ▶ | return unless $die; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | die "Field '$name' not found in '$self'"; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 942 | ▶ | sub sorted_fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sorted_fields: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 942 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 2912 | my @fields = sort { $a->order <=> $b->order } | |||||||||||||||||||||||||||||||||||||||||
| 117 | 942 | grep { $_->is_active } $self->all_fields; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 942 | ▶ | return wantarray ? @fields : \@fields; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | # the routine for looping through and processing each field | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 268 | ▶ | sub _fields_validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fields_validate: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 268 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 268 | ▶ | return unless $self->has_fields; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | # validate all fields | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 268 | my %value_hash; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 268 | foreach my $field ( $self->all_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 129 | 838 | ▶ | next if ( $field->is_inactive || $field->disabled || !$field->has_result ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$field->is_inactive or $field->disabled or not $field->has_result
$field->is_inactive or $field->disabled
MC/DC66%2/3
$field->is_inactive or $field->disabled or not $field->has_result
$field->is_inactive
$field->disabled
not $field->has_result
Truth table75%3/4
A or B or not(C)
A= $field->is_inactiveB= $field->disabledC= not $field->has_result
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | # Validate each field and "inflate" input -> value. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 824 | $field->validate_field; # this calls the field's 'validate' routine | |||||||||||||||||||||||||||||||||||||||||
| 132 | 824 | ▶ | $value_hash{ $field->accessor } = $field->value | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$field->has_value and not $field->noupdate
MC/DC100%2/2
$field->has_value and not $field->noupdate
$field->has_value
not $field->noupdate
Truth table100%3/3
A and not(B)
A= $field->has_valueB= not $field->noupdate
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | if ( $field->has_value && !$field->noupdate ); | ||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 268 | $self->_set_value( \%value_hash ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 177 | ▶ | sub fields_set_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_set_value: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 177 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 177 | my %value_hash; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 177 | foreach my $field ( $self->all_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 142 | 577 | ▶ | next if ( $field->is_inactive || !$field->has_result ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$field->is_inactive or not $field->has_result
MC/DC50%1/2
$field->is_inactive or not $field->has_result
$field->is_inactive
not $field->has_result
Truth table66%2/3
A or not(B)
A= $field->is_inactiveB= not $field->has_result
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 567 | ▶ | $value_hash{ $field->accessor } = $field->value | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$field->has_value and not $field->noupdate
MC/DC100%2/2
$field->has_value and not $field->noupdate
$field->has_value
not $field->noupdate
Truth table100%3/3
A and not(B)
A= $field->has_valueB= not $field->noupdate
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | if ( $field->has_value && !$field->noupdate ); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 177 | $self->_set_value( \%value_hash ); | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 146 | ▶ | sub fields_fif { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_fif: called CC=15 SCAR=27.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 146 | my ( $self, $result, $prefix ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 146 | ▶ | $result ||= $self->result; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$result ||= $self->result
MC/DC0%0/2
$result ||= $self->result
$result
$self->result
Truth table66%2/3
A ||= B
A= $resultB= $self->result
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 146 | ▶ | return unless $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 146 | ▶ | $prefix ||= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$prefix ||= ""
MC/DC100%1/1
$prefix ||= ""
$prefix
Truth table100%2/2
A
A= $prefix
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 146 | ▶ | if ( $self->isa('HTML::FormHandler') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 77 | ▶ | $prefix = $self->name . "." if $self->html_prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 146 | my %params; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 146 | foreach my $fld_result ( $result->results ) { | |||||||||||||||||||||||||||||||||||||||||
| 160 | 413 | my $field = $fld_result->field_def; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 413 | ▶ | next if ( $field->is_inactive || $field->password ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$field->is_inactive or $field->password
MC/DC0%0/2
$field->is_inactive or $field->password
$field->is_inactive
$field->password
Truth table33%1/3
A or B
A= $field->is_inactiveB= $field->password
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 413 | my $fif = $fld_result->fif; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 413 | ▶ | next if ( !defined $fif || (ref $fif eq 'ARRAY' && ! scalar @{$fif} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not defined $fif or ref $fif eq "ARRAY" and not scalar @{$fif;}
ref $fif eq "ARRAY" and not scalar @{$fif;}
MC/DC100%3/3
not defined $fif or ref $fif eq "ARRAY" and not scalar @{$fif;}
not defined $fif
ref $fif eq "ARRAY"
not scalar @{$fif;}
Truth table100%4/4
not(A) or B and not(C)
A= not defined $fifB= ref $fif eq "ARRAY"C= not scalar @{$fif;}
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 403 | ▶ | if ( $fld_result->has_results ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 69 | my $next_params = $fld_result->fields_fif( $prefix . $field->name . '.' ); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 69 | ▶ | next unless $next_params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 68 | %params = ( %params, %{$next_params} ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 334 | $params{ $prefix . $field->name } = $fif; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 146 | ▶ | return if !%params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 144 | return \%params; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 212 | ▶ | sub clear_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_data: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 212 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 212 | $self->clear_result; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 212 | $self->clear_active; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 212 | $_->clear_data for $self->all_fields; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 138 | ▶ | sub propagate_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
propagate_error: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 138 | my ( $self, $result ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | # References to fields with errors are propagated up the tree. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | # All fields with errors should end up being in the form's | ||||||||||||||||||||||||||||||||||||||||||
| 189 | # error_results. Once. | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 138 | my ($found) = grep { $_ == $result } $self->result->all_error_results; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 138 | ▶ | unless ( $found ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 125 | $self->result->add_error_result($result); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 125 | ▶ | if ( $self->parent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 20 | $self->parent->propagate_error( $result ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub dump_fields { shift->dump(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_fields: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | warn "HFH: ------- fields for ", $self->name, "-------\n"; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | for my $field ( $self->sorted_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $field->dump; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | warn "HFH: ------- end fields -------\n"; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub dump_validated { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_validated: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | warn "HFH: fields validated:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | foreach my $field ( $self->sorted_fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | $field->dump_validated if $field->can('dump_validated'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $message = $field->has_errors ? join( ' | ', $field->all_errors) : 'validated'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | warn "HFH: ", $field->name, ": $message\n"; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 147 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 147 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | __END__ | ||||||||||||||||||||||||||||||||||||||||||