| 1 | package HTML::FormHandler::Widget::Wrapper::Simple; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: simple field wrapper | ||||||||||||||||||||||||||||
| 3 | 132 | $HTML::FormHandler::Widget::Wrapper::Simple::VERSION = '0.410002'; | |||||||||||||||||||||||||||
| 4 | 132 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 132 | ▶ | use HTML::Entities qw( encode_entities ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 132 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 132 | ▶ | use HTML::FormHandler::Render::Util ('process_attrs'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 132 | with 'HTML::FormHandler::Widget::Wrapper::Base'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 443 | ▶ | sub wrap_field { | ||||||||||||||||||||||||||
|
Subroutine
wrap_field: called CC=18 SCAR=29.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 443 | my ( $self, $result, $rendered_widget ) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 443 | my $output; | |||||||||||||||||||||||||||
| 17 | # get wrapper tag if set | ||||||||||||||||||||||||||||
| 18 | 443 | ▶ | my $label_tag = $self->label_tag || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->label_tag || ''
MC/DC0%0/1
$self->label_tag || ''
$self->label_tag
Truth table50%1/2
A
A= $self->label_tag
| |||||||||||||||||||||||||||||
| 19 | 443 | my $wrapper_tag; | |||||||||||||||||||||||||||
| 20 | 443 | ▶ | if( $self->do_wrapper ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 394 | $output .= $self->get_tag('before_wrapper'); | |||||||||||||||||||||||||||
| 22 | 394 | $wrapper_tag = $self->get_tag('wrapper_tag'); | |||||||||||||||||||||||||||
| 23 | # default wrapper tags | ||||||||||||||||||||||||||||
| 24 | 394 | ▶ | $wrapper_tag ||= $self->has_flag('is_repeatable') ? 'fieldset' : 'div'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$wrapper_tag ||= $self->has_flag("is_repeatable") ? "fieldset" : "div"
MC/DC0%0/2
$wrapper_tag ||= $self->has_flag("is_repeatable") ? "fieldset" : "div"
$wrapper_tag
$self->has_flag("is_repeatable") ? "fieldset" : "div"
Truth table66%2/3
A ||= B
A= $wrapper_tagB= $self->has_flag("is_repeatable") ? "fieldset" : "div"
| |||||||||||||||||||||||||||||
| 25 | # get attribute string | ||||||||||||||||||||||||||||
| 26 | 394 | my $attrs = process_attrs( $self->wrapper_attributes($result) ); | |||||||||||||||||||||||||||
| 27 | # write wrapper tag | ||||||||||||||||||||||||||||
| 28 | 394 | $output .= qq{\n<$wrapper_tag$attrs>}; | |||||||||||||||||||||||||||
| 29 | 394 | ▶ | $label_tag = 'legend' if $wrapper_tag eq 'fieldset'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | # write label; special processing for checkboxes | ||||||||||||||||||||||||||||
| 32 | 443 | ▶ | $rendered_widget = $self->wrap_checkbox($result, $rendered_widget) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | if ( lc $self->widget eq 'checkbox' ); | ||||||||||||||||||||||||||||
| 34 | 442 | ▶ | $output .= "\n" . $self->do_render_label($result, $label_tag) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | if $self->do_label; | ||||||||||||||||||||||||||||
| 36 | # append 'before_element' | ||||||||||||||||||||||||||||
| 37 | 442 | $output .= $self->get_tag('before_element'); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # start controls div | ||||||||||||||||||||||||||||
| 40 | 442 | ▶ | if ( $self->get_tag('controls_div') ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 41 | 1 | $output .= qq{\n<div class="controls">}; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | elsif ( $self->has_element_wrapper_class ) { | ||||||||||||||||||||||||||||
| 44 | 1 | my $ew_attr = $self->element_wrapper_attributes($result); | |||||||||||||||||||||||||||
| 45 | 1 | my $element_wrapper_attrs = process_attrs( $ew_attr ); | |||||||||||||||||||||||||||
| 46 | 1 | $output .= qq{\n<div$element_wrapper_attrs>}; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # the input element itself | ||||||||||||||||||||||||||||
| 50 | 442 | $output .= "\n$rendered_widget"; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # close controls div | ||||||||||||||||||||||||||||
| 53 | 442 | ▶ | if ( $self->get_tag('controls_div') || $self->has_element_wrapper_class ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->get_tag("controls_div") or $self->has_element_wrapper_class
MC/DC100%2/2
$self->get_tag("controls_div") or $self->has_element_wrapper_class
$self->get_tag("controls_div")
$self->has_element_wrapper_class
Truth table100%3/3
A or B
A= $self->get_tag("controls_div")B= $self->has_element_wrapper_class
| |||||||||||||||||||||||||||||
| 54 | # end control div | ||||||||||||||||||||||||||||
| 55 | 2 | $output .= "\n</div>"; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # the 'after_element' | ||||||||||||||||||||||||||||
| 59 | 442 | $output .= $self->get_tag('after_element'); | |||||||||||||||||||||||||||
| 60 | # the error messages | ||||||||||||||||||||||||||||
| 61 | 442 | ▶ | unless( $self->get_tag('no_errors') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 442 | ▶ | my $error_class = $self->get_tag('error_class') || 'error_message'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->get_tag('error_class') || 'error_message'
MC/DC0%0/1
$self->get_tag('error_class') || 'error_message'
$self->get_tag('error_class')
Truth table50%1/2
A
A= $self->get_tag('error_class')
| |||||||||||||||||||||||||||||
| 63 | $output .= qq{\n<span class="$error_class">$_</span>} | ||||||||||||||||||||||||||||
| 64 | 442 | for map { encode_entities($_) } $result->all_errors; | |||||||||||||||||||||||||||
| 65 | # warnings (incompletely implemented - only on field itself) | ||||||||||||||||||||||||||||
| 66 | 442 | ▶ | my $warning_class = $self->get_tag('warning_class') || 'warning_message'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->get_tag('warning_class') || 'warning_message'
MC/DC0%0/1
$self->get_tag('warning_class') || 'warning_message'
$self->get_tag('warning_class')
Truth table50%1/2
A
A= $self->get_tag('warning_class')
| |||||||||||||||||||||||||||||
| 67 | $output .= qq{\n<span class="warning_message">$_</span>} | ||||||||||||||||||||||||||||
| 68 | 442 | for $result->all_warnings; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 442 | ▶ | if( $self->do_wrapper ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 393 | $output .= "\n</$wrapper_tag>"; | |||||||||||||||||||||||||||
| 72 | 393 | $output .= $self->get_tag('after_wrapper'); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 442 | return "$output"; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 132 | 1; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||||||||||