| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::Password; | ||||||||||||||||||||||||||||||||
| 4 | 6 | $HTML::FormFu::Element::Password::VERSION = '2.06'; | |||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Password form field | ||||||||||||||||||||||||||||||||
| 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::Input'; | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use HTML::FormFu::Constants qw( $EMPTY_STR ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 6 | has render_value => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | after BUILD => sub { | ||||||||||||||||||||||||||||||||
| 19 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 9 | $self->field_type('password'); | |||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 9 | return; | |||||||||||||||||||||||||||||||
| 24 | 6 | }; | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | sub process_value { | ||||||||||||||||||||||||||||||||
| 27 | 12 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
process_value: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 12 | my $submitted = $self->form->submitted; | |||||||||||||||||||||||||||||||
| 30 | 12 | my $new; | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 12 | ▶ | if ( $submitted && $self->render_value ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$submitted and $self->render_value
MC/DC100%2/2
$submitted and $self->render_value
$submitted
$self->render_value
Truth table100%3/3
A and B
A= $submittedB= $self->render_value
| |||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | $new | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | = defined $value | ||||||||||||||||||||||||||||||||
| 35 | ? $value | ||||||||||||||||||||||||||||||||
| 36 | : $EMPTY_STR; | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | if ( $self->retain_default && $new eq $EMPTY_STR ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->retain_default and $new eq $HTML::FormFu::Element::Password::EMPTY_STR
MC/DC50%1/2
$self->retain_default and $new eq $HTML::FormFu::Element::Password::EMPTY_STR
$self->retain_default
$new eq $HTML::FormFu::Element::Password::EMPTY_STR
Truth table66%2/3
A and B
A= $self->retain_defaultB= $new eq $HTML::FormFu::Element::Password::EMPTY_STR
| |||||||||||||||||||||||||||||||||
| 39 | 2 | $new = $self->value; | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 5 | $self->value($new); | |||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | elsif ($submitted) { | ||||||||||||||||||||||||||||||||
| 45 | 3 | $new = $EMPTY_STR; | |||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | else { | ||||||||||||||||||||||||||||||||
| 48 | 4 | $new = undef; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 12 | return $new; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 6 | 1; | |||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | =pod | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | HTML::FormFu::Element::Password - Password form field | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | =head1 VERSION | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | version 2.06 | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | my $element = $form->element( Password => 'foo' ); | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | Password form field. | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | =head2 render_value | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | Normally, when a form is redisplayed because of errors, password fields | ||||||||||||||||||||||||||||||||
| 85 | lose their values, requiring the user to retype it. | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | If C<render_value> is true, password fields won't lose their value. | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | Default value: false | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | Is a sub-class of, and inherits methods from | ||||||||||||||||||||||||||||||||
| 94 | L<HTML::FormFu::Role::Element::Input>, | ||||||||||||||||||||||||||||||||
| 95 | L<HTML::FormFu::Role::Element::Field>, | ||||||||||||||||||||||||||||||||
| 96 | L<HTML::FormFu::Element> | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | L<HTML::FormFu> | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | Carl Franks, C<cfranks@cpan.org> | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | =head1 LICENSE | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||
| 107 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||
| 118 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||||||