/lib/HTML/FormHandler/Widget/Wrapper/Table.pm
Perl | 32 lines | 26 code | 5 blank | 1 comment | 7 complexity | a977fd99ceaae5dcbb9ce7f8e1a9034a MD5 | raw file
1package HTML::FormHandler::Widget::Wrapper::Table; 2# ABSTRACT: wrapper class for table layout 3 4use Moose::Role; 5with 'HTML::FormHandler::Widget::Wrapper::Base'; 6use HTML::FormHandler::Render::Util ('process_attrs'); 7 8sub wrap_field { 9 my ( $self, $result, $rendered_widget ) = @_; 10 11 return $rendered_widget if ( $self->has_flag('is_compound') && $self->get_tag('no_compound_wrapper') ); 12 13 my $output = "\n<tr" . process_attrs($self->wrapper_attributes($result)) . ">"; 14 if ( $self->has_flag('is_compound') ) { 15 $output .= '<td>' . $self->do_render_label($result) . '</td></tr>'; 16 } 17 elsif ( $self->do_label && length( $self->label ) > 0 ) { 18 $output .= '<td>' . $self->do_render_label($result) . '</td>'; 19 } 20 if ( !$self->has_flag('is_compound') ) { 21 $output .= '<td>'; 22 } 23 $output .= $rendered_widget; 24 $output .= qq{\n<span class="error_message">$_</span>} for $result->all_errors; 25 if ( !$self->has_flag('is_compound') ) { 26 $output .= "</td></tr>\n"; 27 } 28 return $output; 29} 30 31use namespace::autoclean; 321;