FormHandler/Render/Table.pm

filter: Statementstmt 88.2% 45 / 51 Branchbran 83.3% 10 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 5 totaltotal 83.1% 64 / 77 CC 10 SCAR 14.4
CC
10
Cov
87%
wrap_field
7.0
render_form_errors
5.7
render
2.0
CRAP 4.2
« FormHandler/Widget/Field/Captcha.pm ↑ Summary FormHandler/Field/Password.pm »
1 package HTML::FormHandler::Render::Table;
2 # ABSTRACT: render a form with a table layout
3 4 $HTML::FormHandler::Render::Table::VERSION = '0.410002';
4 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 with 'HTML::FormHandler::Render::Simple' =>
7 { -excludes => [ 'render', 'wrap_field', 'render_end', 'render_start' ] };
8 4 ▶use HTML::FormHandler::Render::Util ('process_attrs');
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use HTML::Entities qw( encode_entities );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 3 ▶sub render {
Subroutine render: called CC=2 SCAR=6.9
Pod undocumented
13 3 my $self = shift;
14  
15 3 my $output = $self->render_start;
16 3 $output .= $self->render_form_errors;
17 3 foreach my $field ( $self->sorted_fields ) {
18 21 $output .= $self->render_field($field);
19 }
20 3 $output .= $self->render_end;
21 3 return $output;
22 }
23  
24 3 ▶sub render_start {
Subroutine render_start: called CC=1 SCAR=0.0
Pod undocumented
25 3 my $self = shift;
26  
27 3 my $attrs = process_attrs($self->attributes);
28 3 return qq{<form$attrs><table>};
29 }
30  
31 3 ▶sub render_form_errors {
Subroutine render_form_errors: called CC=3 SCAR=17.3
Pod undocumented
32 3 my $self = shift;
33  
34 3 ▶ return '' unless $self->has_form_errors;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_form_errors 3 0 3
35 0 my $output = "\n<tr class=\"form_errors\"><td colspan=\"2\">";
36 $output .= qq{\n<span class="error_message">$_</span>}
37 0 for map { encode_entities($_) } $self->all_form_errors;
38 0 $output .= "\n</td></tr>";
39 0 return $output;
40 }
41  
42 3 ▶sub render_end {
Subroutine render_end: called CC=1 SCAR=0.0
Pod undocumented
43 3 my $self = shift;
44 3 my $output = "</table>\n";
45 3 $output .= "</form>\n";
46 3 return $output;
47 }
48  
49 24 ▶sub wrap_field {
Subroutine wrap_field: called CC=7 SCAR=19.5
Pod undocumented
50 24 my ( $self, $field, $rendered_field ) = @_;
51  
52 24 my $attrs = process_attrs($field->wrapper_attributes);
53 24 my $output = qq{\n<tr$attrs>};
54 24 ▶ my $l_type = $field->widget eq 'Compound' ? 'legend' : 'label';
Branch: 1 branch
BranchTrueFalseTotal
$field->widget eq 'Compound' ? : 1 23 24
55 24 ▶ if ( $l_type eq 'label' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($l_type eq 'label') { } 23 1 24
elsif ($l_type eq 'legend') { } 1 0 1
56 23 $output .= '<td>' . $self->render_label($field) . '</td>';
57 }
58 elsif ( $l_type eq 'legend' ) {
59 1 $output .= '<td>' . $self->render_label($field) . '</td></tr>';
60 }
61 24 ▶ if ( $l_type ne 'legend' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l_type ne "legend") 23 1 24
62 23 $output .= '<td>';
63 }
64 24 $output .= $rendered_field;
65 $output .= qq{\n<span class="error_message">$_</span>}
66 0 for map { encode_entities($_) } $field->all_errors;
67 24 ▶ if ( $l_type ne 'legend' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l_type ne "legend") 23 1 24
68 23 $output .= "</td></tr>\n";
69 }
70 24 return $output;
71 }
72  
73 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 4 1;
75  
76 __END__
« FormHandler/Widget/Field/Captcha.pm ↑ Summary FormHandler/Field/Password.pm »