Debian Codegraph @

lib/HTML/FormHandler/Widget/Wrapper/Table.pm

raw
1 package HTML::FormHandler::Widget::Wrapper::Table;
2 # ABSTRACT: wrapper class for table layout
3 $HTML::FormHandler::Widget::Wrapper::Table::VERSION = '0.410002';
4 use Moose::Role;
5 with 'HTML::FormHandler::Widget::Wrapper::Base';
6 use HTML::FormHandler::Render::Util ('process_attrs');
7 use HTML::Entities qw( encode_entities );
8
9 sub wrap_field {
10 my ( $self, $result, $rendered_widget ) = @_;
11
12 return $rendered_widget if ( $self->has_flag('is_compound') && $self->get_tag('no_compound_wrapper') );
13
14 my $output = "\n<tr" . process_attrs($self->wrapper_attributes($result)) . ">";
15 if ( $self->has_flag('is_compound') ) {
16 $output .= '<td>' . $self->do_render_label($result) . '</td></tr>';
17 }
18 elsif ( $self->do_label && length( $self->label ) > 0 ) {
19 $output .= '<td>' . $self->do_render_label($result) . '</td>';
20 }
21 if ( !$self->has_flag('is_compound') ) {
22 $output .= '<td>';
23 }
24 $output .= $rendered_widget;
25 $output .= qq{\n<span class="error_message">$_</span>}
26 for map { encode_entities($_) } $result->all_errors;
27 if ( !$self->has_flag('is_compound') ) {
28 $output .= "</td></tr>\n";
29 }
30 return $output;
31 }
32
33 use namespace::autoclean;
34 1;
35
36 __END__
37
38 =pod
39
40 =encoding UTF-8
41
42 =head1 NAME
43
44 HTML::FormHandler::Widget::Wrapper::Table - wrapper class for table layout
45
46 =head1 VERSION
47
48 version 0.410002
49
50 =head1 AUTHOR
51
52 FormHandler Contributors - see HTML::FormHandler
53
54 =head1 COPYRIGHT AND LICENSE
55
56 This software is copyright (c) 2017 by Gerda Shank.
57
58 This is free software; you can redistribute it and/or modify it under
59 the same terms as the Perl 5 programming language system itself.
60
61 =cut