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