File Coverage

blib/lib/HTML/FormHandler/Widget/Field/Compound.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 4 50.0
condition 3 6 50.0
subroutine 5 5 100.0
pod 0 3 0.0
total 32 40 80.0


line stmt bran cond sub pod time code
1             package HTML::FormHandler::Widget::Field::Compound;
2             # ABSTRACT: compound field widget
3             $HTML::FormHandler::Widget::Field::Compound::VERSION = '0.40068';
4 55     55   41019 use Moose::Role;
  55         164  
  55         3887  
5              
6              
7             sub render_subfield {
8 119     119 0 319 my ( $self, $result, $subfield ) = @_;
9 119         3150 my $subresult = $result->field( $subfield->name );
10              
11 119 50       427 return "" unless $subresult;
12 119         674 return $subfield->render( $subresult );
13             }
14              
15             sub render_element {
16 81     81 0 216 my ( $self, $result ) = @_;
17 81   33     268 $result ||= $self->result;
18              
19 81         193 my $output = '';
20 81         480 foreach my $subfield ( $self->sorted_fields ) {
21 170         744 $output .= $self->render_subfield( $result, $subfield );
22             }
23 81         491 $output =~ s/^\n//; # remove newlines so they're not duplicated
24 81         275 return $output;
25             }
26              
27             sub render {
28 81     81 0 249 my ( $self, $result ) = @_;
29 81   66     875 $result ||= $self->result;
30 81 50       256 die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result;
31 81         354 my $output = $self->render_element( $result );
32 81         379 return $self->wrap_field( $result, $output );
33             }
34              
35 55     55   305020 use namespace::autoclean;
  55         164  
  55         540  
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding UTF-8
43              
44             =head1 NAME
45              
46             HTML::FormHandler::Widget::Field::Compound - compound field widget
47              
48             =head1 VERSION
49              
50             version 0.40068
51              
52             =head1 SYNOPSIS
53              
54             Widget for rendering a compound field.
55              
56             =head1 AUTHOR
57              
58             FormHandler Contributors - see HTML::FormHandler
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             This software is copyright (c) 2017 by Gerda Shank.
63              
64             This is free software; you can redistribute it and/or modify it under
65             the same terms as the Perl 5 programming language system itself.
66              
67             =cut