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.40067';
4 55     55   45137 use Moose::Role;
  55         84  
  55         438  
5              
6              
7             sub render_subfield {
8 119     119 0 172 my ( $self, $result, $subfield ) = @_;
9 119         2805 my $subresult = $result->field( $subfield->name );
10              
11 119 50       264 return "" unless $subresult;
12 119         491 return $subfield->render( $subresult );
13             }
14              
15             sub render_element {
16 81     81 0 101 my ( $self, $result ) = @_;
17 81   33     293 $result ||= $self->result;
18              
19 81         122 my $output = '';
20 81         362 foreach my $subfield ( $self->sorted_fields ) {
21 170         517 $output .= $self->render_subfield( $result, $subfield );
22             }
23 81         350 $output =~ s/^\n//; # remove newlines so they're not duplicated
24 81         195 return $output;
25             }
26              
27             sub render {
28 81     81 0 129 my ( $self, $result ) = @_;
29 81   66     741 $result ||= $self->result;
30 81 50       177 die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result;
31 81         267 my $output = $self->render_element( $result );
32 81         274 return $self->wrap_field( $result, $output );
33             }
34              
35 55     55   208797 use namespace::autoclean;
  55         84  
  55         436  
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.40067
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) 2016 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