| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::Label; | ||||||||||||||||||||||||||||
| 4 | 6 | $HTML::FormFu::Element::Label::VERSION = '2.09'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: field for displaying only | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 6 | extends "HTML::FormFu::Element"; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 6 | with 'HTML::FormFu::Role::Element::Field', | |||||||||||||||||||||||||||
| 13 | 'HTML::FormFu::Role::Element::SingleValueField', | ||||||||||||||||||||||||||||
| 14 | 'HTML::FormFu::Role::Element::Coercible'; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use HTML::FormFu::Util qw( process_attrs ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use List::Util 1.33 qw( none ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 6 | has field_type => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 6 | has tag => ( | |||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | default => 'span', | ||||||||||||||||||||||||||||
| 24 | lazy => 1, | ||||||||||||||||||||||||||||
| 25 | traits => ['Chained'], | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 6 | ▶ | after BUILD => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 6 | $self->layout_field_filename('field_layout_label_field'); | |||||||||||||||||||||||||||
| 32 | 6 | $self->non_param(1); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | #$self->field_type('label'); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 6 | $self->model_config->{read_only} = 1; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 6 | return; | |||||||||||||||||||||||||||
| 39 | 6 | }; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 5 | ▶ | sub _string_field { | ||||||||||||||||||||||||||
|
Subroutine
_string_field: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 42 | 5 | my ( $self, $render ) = @_; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 5 | my $html .= "<" . $self->tag; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 5 | ▶ | $html .= sprintf "%s", process_attrs( $render->{attributes} || {} ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$render->{'attributes'} || {}
MC/DC0%0/1
$render->{'attributes'} || {}
$render->{'attributes'}
Truth table50%1/2
A
A= $render->{'attributes'}
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 5 | ▶ | if ( defined $render->{nested_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 5 | $html .= sprintf qq{ name="%s"}, $render->{nested_name}; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 5 | $html .= ">"; | |||||||||||||||||||||||||||
| 52 | 5 | ▶ | if ( defined $render->{value} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 4 | $html .= sprintf qq{%s}, $render->{value}; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 5 | $html .= "</" . $self->tag . ">"; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | return $html; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 5 | ▶ | sub process_input { | ||||||||||||||||||||||||||
|
Subroutine
process_input: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 61 | 5 | my ( $self, $input ) = @_; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 5 | my $form = $self->form; | |||||||||||||||||||||||||||
| 64 | 5 | my $name = $self->nested_name; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 5 | ▶ | if ( $form->submitted | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$form->submitted and $form->nested_hash_key_exists($input, $name)
MC/DC50%1/2
$form->submitted and $form->nested_hash_key_exists($input, $name)
$form->submitted
$form->nested_hash_key_exists($input, $name)
Truth table66%2/3
A and B
A= $form->submittedB= $form->nested_hash_key_exists($input, $name)
| |||||||||||||||||||||||||||||
| 67 | && $form->nested_hash_key_exists( $input, $name ) ) | ||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | 2 | my @fields = @{ $form->get_fields( { nested_name => $name } ) }; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 2 | ▶ | if ( none { $_ == $self } @fields ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $form->delete_nested_hash_key( $input, $name ); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 5 | return; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 5 | ▶ | sub render_data_non_recursive { | ||||||||||||||||||||||||||
|
Subroutine
render_data_non_recursive: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 80 | 5 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 5 | ▶ | my $render = $self->SUPER::render_data_non_recursive( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | { tag => $self->tag, | ||||||||||||||||||||||||||||
| 84 | $args ? %$args : (), | ||||||||||||||||||||||||||||
| 85 | } ); | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 5 | return $render; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 6 | 1; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||