| 1 | package HTML::FormHandler::Widget::Form::Role::HTMLAttributes; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: set HTML attributes on the form tag | ||||||||||||||||||||||||||||
| 3 | 147 | $HTML::FormHandler::Widget::Form::Role::HTMLAttributes::VERSION = '0.410002'; | |||||||||||||||||||||||||||
| 4 | 147 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 0 | ▶ | sub html_form_tag { | ||||||||||||||||||||||||||
|
Subroutine
html_form_tag: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | my @attr_accessors = ( | |||||||||||||||||||||||||||
| 10 | [ action => 'action' ], | ||||||||||||||||||||||||||||
| 11 | [ id => 'name' ], | ||||||||||||||||||||||||||||
| 12 | [ method => 'http_method' ], | ||||||||||||||||||||||||||||
| 13 | [ enctype => 'enctype' ], | ||||||||||||||||||||||||||||
| 14 | [ style => 'style' ], | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # make the element_attr a safe default | ||||||||||||||||||||||||||||
| 18 | 0 | my $element_attr = {}; | |||||||||||||||||||||||||||
| 19 | # Assuming that self is a form | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $element_attr = { %{$self->form_element_attr} } if ( $self->can( 'form_element_attr' ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | # Assuming that self is a field | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $element_attr = { %{$self->element_attr} } if ( $self->can( 'element_attr' ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | foreach my $attr_pair (@attr_accessors) { | |||||||||||||||||||||||||||
| 25 | 0 | my $attr = $attr_pair->[0]; | |||||||||||||||||||||||||||
| 26 | 0 | my $accessor = $attr_pair->[1]; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( !exists $element_attr->{$attr} && defined( my $value = $self->$accessor ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $element_attr->{$attr} and defined(my $value = $self->$accessor)
MC/DC0%0/2
not exists $element_attr->{$attr} and defined(my $value = $self->$accessor)
not exists $element_attr->{$attr}
defined(my $value = $self->$accessor)
Truth table0%0/3
not(A) and B
A= not exists $element_attr->{$attr}B= defined(my $value = $self->$accessor)
| |||||||||||||||||||||||||||||
| 28 | 0 | $element_attr->{$attr} = $self->$accessor; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | my $output = '<form'; | |||||||||||||||||||||||||||
| 33 | 0 | foreach my $attr ( sort keys %$element_attr ) { | |||||||||||||||||||||||||||
| 34 | 0 | $output .= qq{ $attr="} . $element_attr->{$attr} . qq{"}; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | $output .= " >\n"; | |||||||||||||||||||||||||||
| 38 | 0 | return $output; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 147 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 147 | 1; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||||||||||