File Coverage

blib/lib/HTML/FormHandler/Widget/Field/Repeatable.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 4 50.0
condition 1 6 16.6
subroutine 3 3 100.0
pod 0 1 0.0
total 19 27 70.3


line stmt bran cond sub pod time code
1             package HTML::FormHandler::Widget::Field::Repeatable;
2             # ABSTRACT: repeatable field widget
3             $HTML::FormHandler::Widget::Field::Repeatable::VERSION = '0.40068';
4 28     28   21424 use Moose::Role;
  28         87  
  28         360  
5             with 'HTML::FormHandler::Widget::Field::Compound';
6              
7              
8             has 'wrap_repeatable_element_method' => (
9             traits => ['Code'],
10             is => 'ro',
11             isa => 'CodeRef',
12             handles => { 'wrap_repeatable_element' => 'execute_method' },
13             );
14              
15             sub render_subfield {
16 51     51 0 154 my ( $self, $result, $subfield ) = @_;
17              
18 51         1655 my $subresult = $result->field( $subfield->name );
19              
20 51 0 0     185 return "" unless $subresult
      33        
21             or ( $self->has_flag( "is_repeatable")
22             and $subfield->name < $self->num_when_empty
23             );
24              
25 51         320 my $output = $subfield->render($subresult);
26 51 100       1680 if ( $self->wrap_repeatable_element_method ) {
27 2         49 $output = $self->wrap_repeatable_element($output, $subfield->name);
28             }
29 51         306 return $output;
30             }
31              
32 28     28   155118 use namespace::autoclean;
  28         88  
  28         308  
33             1;
34              
35             __END__
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             HTML::FormHandler::Widget::Field::Repeatable - repeatable field widget
44              
45             =head1 VERSION
46              
47             version 0.40068
48              
49             =head1 SYNOPSIS
50              
51             Renders a repeatable field
52              
53             =head1 AUTHOR
54              
55             FormHandler Contributors - see HTML::FormHandler
56              
57             =head1 COPYRIGHT AND LICENSE
58              
59             This software is copyright (c) 2017 by Gerda Shank.
60              
61             This is free software; you can redistribute it and/or modify it under
62             the same terms as the Perl 5 programming language system itself.
63              
64             =cut