| 1 |
package HTML::FormHandler::Manual::FromDFV; |
| 2 |
# ABSTRACT: converting from Data::FormValidator |
| 3 |
|
| 4 |
__END__ |
| 5 |
|
| 6 |
=pod |
| 7 |
|
| 8 |
=encoding UTF-8 |
| 9 |
|
| 10 |
=head1 NAME |
| 11 |
|
| 12 |
HTML::FormHandler::Manual::FromDFV - converting from Data::FormValidator |
| 13 |
|
| 14 |
=head1 VERSION |
| 15 |
|
| 16 |
version 0.410002 |
| 17 |
|
| 18 |
=head1 SYNOPSIS |
| 19 |
|
| 20 |
L<Manual Index|HTML::FormHandler::Manual> |
| 21 |
|
| 22 |
Cheatsheet for converting from L<Data::FormValidator>. |
| 23 |
|
| 24 |
=head1 DESCRIPTION |
| 25 |
|
| 26 |
Information that's useful when switching from Data::FormValidator to |
| 27 |
HTML::FormHandler. There's not a lot here yet, so if you have something |
| 28 |
to add, patches are welcome. |
| 29 |
|
| 30 |
In a general way, FormHandler doesn't have nearly so many "special" |
| 31 |
checks as Data::FormValidator. It would be possible to implement many |
| 32 |
of them, but there hasn't been much demand for them. So far FormHandler |
| 33 |
users seem to be satisfied with the "do your own checks in a Perl method" |
| 34 |
solution. Because of the greater complexity of FormHandler's data model - |
| 35 |
with Repeatable arrays and nested compounds, etc - it's somewhat harder |
| 36 |
to do some of them automatically. |
| 37 |
|
| 38 |
=head1 Differences/conversions |
| 39 |
|
| 40 |
=over 4 |
| 41 |
|
| 42 |
=item dependencies |
| 43 |
|
| 44 |
In FormHandler, 'dependency' is the equivalent of 'dependency_group', |
| 45 |
without the key names. |
| 46 |
|
| 47 |
The other variations of dependencies in DFV are not implemented in |
| 48 |
FormHandler, and would normally be done in a form's 'validate' sub. |
| 49 |
|
| 50 |
=item trim, filters |
| 51 |
|
| 52 |
A 'trim' filter is installed by default in FormHandler; it's a |
| 53 |
special version of an apply action, and can be set to a transform |
| 54 |
or Moose type. See the documentation in L<HTML::FormHandler::Field#trim>. |
| 55 |
|
| 56 |
Transforms and inflations/deflations do not change what is presented in |
| 57 |
the form unless you set the 'fif_from_value' flag on the field. |
| 58 |
|
| 59 |
=item FV_length_between, FV_max_length, FV_min_length |
| 60 |
|
| 61 |
Use text fields with 'minlength' and 'maxlength' attributes. |
| 62 |
|
| 63 |
=item FV_eq_with |
| 64 |
|
| 65 |
Perform your own checks in the form 'validate' sub. |
| 66 |
|
| 67 |
sub validate { |
| 68 |
my $self = shift; |
| 69 |
if( $self->field('one')->value eq $self->field('two')->value ) { |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
=back |
| 74 |
|
| 75 |
=head1 Constraints |
| 76 |
|
| 77 |
The simple constraints from L<Data::FormValidator::Constraints> can be used |
| 78 |
directly in a FormHandler form: |
| 79 |
|
| 80 |
use Data::FormValidator::Constraints ('match_state'); |
| 81 |
has_field 'my_state' => ( |
| 82 |
apply => [ { check => \&match_state, message => 'Invalid State' } ] ); |
| 83 |
|
| 84 |
=over 4 |
| 85 |
|
| 86 |
=item email |
| 87 |
|
| 88 |
Use the 'Email' field type, or use the FH Moose Type, 'email'. |
| 89 |
|
| 90 |
has_field 'email' => ( type => 'Email' ); |
| 91 |
-- or -- |
| 92 |
use HTML::FormHandler::Types ('Email'); |
| 93 |
has_field 'email' => ( apply => [ Email ] ); |
| 94 |
|
| 95 |
=back |
| 96 |
|
| 97 |
=head1 AUTHOR |
| 98 |
|
| 99 |
FormHandler Contributors - see HTML::FormHandler |
| 100 |
|
| 101 |
=head1 COPYRIGHT AND LICENSE |
| 102 |
|
| 103 |
This software is copyright (c) 2017 by Gerda Shank. |
| 104 |
|
| 105 |
This is free software; you can redistribute it and/or modify it under |
| 106 |
the same terms as the Perl 5 programming language system itself. |
| 107 |
|
| 108 |
=cut |