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