File Coverage

blib/lib/HTML/FormFu/Plugin/StashValid.pm
Criterion Covered Total %
statement 12 12 100.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package HTML::FormFu::Plugin::StashValid;
2              
3 3     3   864 use strict;
  3         5  
  3         163  
4             our $VERSION = '2.05'; # VERSION
5              
6 3     3   13 use Moose;
  3         3  
  3         19  
7             extends 'HTML::FormFu::Plugin';
8              
9             sub post_process {
10 2     2 1 3 my ($self) = @_;
11              
12 2         13 my $form = $self->form;
13 2         9 my $name = $self->parent->nested_name;
14              
15 2 50       10 if ( $form->valid($name) ) {
16 2         9 $form->stash->{$name} = $form->param($name);
17             }
18              
19 2         6 return;
20             }
21              
22             __PACKAGE__->meta->make_immutable;
23              
24             1;
25              
26             __END__
27              
28             =head1 NAME
29              
30             HTML::FormFu::Plugin::StashValid - place valid params on form stash
31              
32             =head1 VERSION
33              
34             version 2.05
35              
36             =head1 SYNOPSIS
37              
38             # called on a form or block
39             ---
40             plugins:
41             - type: StashValid
42             names: ['field-names']
43              
44             # called on a field
45             ---
46             elements:
47             - name: foo
48             plugins:
49             - StashValid
50              
51             =head1 DESCRIPTION
52              
53             Run during the L<HTML::FormFu::Plugin/post_process> hook (called during
54             L<HTML::FormFu/process>).
55             If the named field(s) have a valid value after processing, that value is
56             placed on the form stash, using the field-name as the stash-key.
57              
58             =head1 METHODS
59              
60             Arrayref of field names, whose valid values should be stashed.
61              
62             =head1 SEE ALSO
63              
64             Is a sub-class of, and inherits methods from L<HTML::FormFu::Plugin>
65              
66             L<HTML::FormFu>
67              
68             =head1 AUTHOR
69              
70             Carl Franks C<cfranks@cpan.org>
71              
72             =head1 LICENSE
73              
74             This library is free software, you can redistribute it and/or modify it under
75             the same terms as Perl itself.
76              
77             =cut