lib/HTML/FormFu/Plugin/StashValid.pm

filter: Statementstmt 100% 16 / 16 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 95.4% 21 / 22 SCAR 6.9
CC
2
Cov
94%
post_process
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« lib/HTML/FormFu/Element/Image.pm ↑ Summary lib/HTML/FormFu/Element/Fieldset.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Plugin::StashValid;
4 3 $HTML::FormFu::Plugin::StashValid::VERSION = '2.06';
5 # ABSTRACT: place valid params on form stash
6  
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 extends 'HTML::FormFu::Plugin';
9  
10 sub post_process {
11 2 ▶ my ($self) = @_;
Subroutine post_process: called CC=2 SCAR=7.0
Pod documented
12  
13 2 my $form = $self->form;
14 2 my $name = $self->parent->nested_name;
15  
16 2 ▶ if ( $form->valid($name) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form->valid($name)) 2 0 2
17 2 $form->stash->{$name} = $form->param($name);
18 }
19  
20 2 return;
21 }
22  
23 3 __PACKAGE__->meta->make_immutable;
24  
25 3 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.06
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
« lib/HTML/FormFu/Element/Image.pm ↑ Summary lib/HTML/FormFu/Element/Fieldset.pm »