| 1 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::Label; | ||||||||||||||||||||||||||||
| 4 | 4 | $HTML::FormFu::Element::Label::VERSION = '2.06'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: field for displaying only | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | extends "HTML::FormFu::Element"; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | with 'HTML::FormFu::Role::Element::Field', | |||||||||||||||||||||||||||
| 13 | 'HTML::FormFu::Role::Element::SingleValueField', | ||||||||||||||||||||||||||||
| 14 | 'HTML::FormFu::Role::Element::Coercible'; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use HTML::FormFu::Util qw( process_attrs ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use List::Util 1.33 qw( none ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | has field_type => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | has tag => ( | |||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | default => 'span', | ||||||||||||||||||||||||||||
| 24 | lazy => 1, | ||||||||||||||||||||||||||||
| 25 | traits => ['Chained'], | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | after BUILD => sub { | ||||||||||||||||||||||||||||
| 29 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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 | 4 | }; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub _string_field { | ||||||||||||||||||||||||||||
| 42 | 5 | ▶ | my ( $self, $render ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_string_field: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 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 | sub process_input { | ||||||||||||||||||||||||||||
| 61 | 5 | ▶ | my ( $self, $input ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
process_input: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 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 | sub render_data_non_recursive { | ||||||||||||||||||||||||||||
| 80 | 5 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
render_data_non_recursive: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 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 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 4 | 1; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =pod | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 NAME | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | HTML::FormFu::Element::Label - field for displaying only | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 VERSION | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | version 2.06 | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | This element displays a value. This is useful if you use a model like | ||||||||||||||||||||||||||||
| 111 | L<HTML::FormFu::Model::DBIC> and want to display a value from the database. | ||||||||||||||||||||||||||||
| 112 | The value of this field cannot be set by the client. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | See L<HTML::FormFu::Model::DBIC/"Set a field read only"> for more information | ||||||||||||||||||||||||||||
| 115 | on read only fields. | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head1 METHODS | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head2 tag | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Set the tag for this element. | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | Is a sub-class of, and inherits methods from | ||||||||||||||||||||||||||||
| 126 | L<HTML::FormFu::Role::Element::Field>, L<HTML::FormFu::Element> | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | L<HTML::FormFu> | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | Moritz Onken, C<< onken at houseofdesign.de >> | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 137 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 148 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||