.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "HTML::FormHandler::Manual::FromFF 3pm" .TH HTML::FormHandler::Manual::FromFF 3pm "2017-11-11" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HTML::FormHandler::Manual::FromFF \- converting from HTML::FormFu .SH "VERSION" .IX Header "VERSION" version 0.40068 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Manual Index .PP Cheatsheet for converting from HTML::FormFu. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Information that may be useful when converting to FormHandler from FormFu. .SS "Inside/Outside" .IX Subsection "Inside/Outside" FormFu forms look to me like \*(L"inside-out\*(R" objects. The attributes and code are all set outside of the object. FormHandler forms are the opposite. Almost all attributes and settings are set *inside* the form class, although settings can be passed in on 'new' and 'process', of course. FormHandler fields are built as part of the object construction process, so you do not create or add new fields after the form instance has been constructed. There are many facilities for setting fields active/inactive or changing the various field attributes, so this is not limiting in what you can do. .PP One of the big advantages of having form fields and validations, etc, inside the object is that it makes it a lot easier to test exactly what you're using in your controllers. .SS "Config files" .IX Subsection "Config files" There are so many drawbacks to using config files to specify your forms that I don't see why anybody would voluntarily do it. However it takes all kinds, so if you really want to use config files, you can...mostly. There are a lot of things you can't do in config files, but FormHandler provides so many ways of doing things, that you can probably get it to work. And sometimes it's easier to update forms piecemeal, or there may be policies in place, so if you really want/need config files for building forms, see HTML::FormHandler::Foo and the test in t/form_setup/config.t. .SS "Rendering" .IX Subsection "Rendering" You should be able to make your FormHandler forms automatically render very close to FormFu's rendering. There's an example of simple FormFu-like rendering in t/render/ff.t. Set up a base class with the necessary code, and your forms could be practically drop-in replacements from a rendering perspective. .SH "Filters, Constraints, Inflators, Validators, Transformers" .IX Header "Filters, Constraints, Inflators, Validators, Transformers" FormHandler doesn't distinguish between these categories in the same way that FormFu does. FormHandler has inflation/deflation, validation methods, and apply actions. The distinguishing factor is mostly where it happens in the process. .SS "Filters" .IX Subsection "Filters" A 'trim' filter is installed by default in FormHandler; it's a special version of an apply action, and can be set to a transform or Moose type. See the documentation in HTML::FormHandler::Field#trim. .PP An \s-1HTML\s0 filter is applied by default in certain places in the rendering. You can change it with the 'render_filter' attribute. See HTML::FormHandler::Manual::Rendering#Rendering\-filter. .PP You can change the form of the field's value using a number of inflation/deflation methods, or a transform, or a Moose type. See HTML::FormHandler::Manual::InflationDeflation and HTML::FormHandler::Manual::Validation. .PP Transforms and inflations/deflations do not change what is presented in the form unless you set the 'fif_from_value' flag on the field (the rough equivalent of FormFu's 'render_processed_value'). .PP \fIFormatNumber\fR .IX Subsection "FormatNumber" .PP Use an inflation: .PP .Vb 5 \& has_field \*(Aqfoo\*(Aq => ( type => \*(AqPosInteger\*(Aq, inflate_method => \e&format_number ); \& sub format_number { \& my ( $self, $value ) = @_; \& return unformat_number( $value ); \& } .Ve .SS "Constraints" .IX Subsection "Constraints" A lot of these are simple regexes or functions. If they're things you're going to use often, you probably want to put them in a type library or validator class. .IP "AllOrNone" 4 .IX Item "AllOrNone" Not implemented. Do this in a form 'validate' sub. .IP "\s-1ASCII\s0" 4 .IX Item "ASCII" A simple regex: .Sp .Vb 2 \& has foo => ( apply => [ { check => qr/^\ep{IsASCII}*\ez/, \& message => \*(AqNot a valid string\*(Aq } ] ); .Ve .IP "AutoSet" 4 .IX Item "AutoSet" Not necessary. This is done automatically by FormHandler. You'd have to go to some work to avoid it. .IP "Bool" 4 .IX Item "Bool" A simple regex: .Sp .Vb 1 \& qr/^[01]?\ez/ .Ve .Sp Or you can use the Boolean field. .IP "Callback, CallbackOnce" 4 .IX Item "Callback, CallbackOnce" This is just validation done in code. Use one of the many places you can put validation in methods in FormHandler. See HTML::FormHandler::Manual::Validation. .IP "DateTime" 4 .IX Item "DateTime" Use Date or DateTime field or make your own. .IP "DependOn" 4 .IX Item "DependOn" Use 'dependency' attribute in the form. Or do more complicated things in the form's 'validate' sub. .IP "Email" 4 .IX Item "Email" Use the 'Email' field type, or use the \s-1FH\s0 Moose Type, 'email'. .Sp .Vb 4 \& has_field \*(Aqemail\*(Aq => ( type => \*(AqEmail\*(Aq ); \& \-\- or \-\- \& use HTML::FormHandler::Types (\*(AqEmail\*(Aq); \& has_field \*(Aqemail\*(Aq => ( apply => [ Email ] ); .Ve .IP "Equal" 4 .IX Item "Equal" No equivalent. Perform this check in the form's 'validate' sub. .IP "File" 4 .IX Item "File" Use 'Upload' field. .IP "Integer" 4 .IX Item "Integer" Use 'Integer' field. .IP "Length, MaxLength, MinLength" 4 .IX Item "Length, MaxLength, MinLength" Use 'minlength' and 'maxlength' on the Text field and its subclasses. .IP "Range, MaxRange, MinRange" 4 .IX Item "Range, MaxRange, MinRange" Use 'range_start' and 'range_end'. .IP "MinMaxFields" 4 .IX Item "MinMaxFields" No equivalent. .IP "Number" 4 .IX Item "Number" Use Moose type 'Num'. .IP "Printable" 4 .IX Item "Printable" Use FormHandler Moose type 'Printable'. .IP "reCAPTCHA" 4 .IX Item "reCAPTCHA" Use Captcha field or HTML::FormHandlerX::Field::reCAPTCHA. .IP "Regex" 4 .IX Item "Regex" Use 'check' action with regex. .IP "Required" 4 .IX Item "Required" Set 'required' flag on the field. .IP "Set" 4 .IX Item "Set" Use 'check' action with arrayref of strings. .IP "SingleValue" 4 .IX Item "SingleValue" Not necessary. .IP "Word" 4 .IX Item "Word" This is a simple regex: .Sp .Vb 1 \& qr/^\ew*\ez/ .Ve .Sp Substitute FormHandler Moose type 'SingleWord'. .SS "Inflators" .IX Subsection "Inflators" Use one of the inflation/deflation methods. See HTML::FormHandler::Manual::InflationDeflation. .SS "Validators" .IX Subsection "Validators" See HTML::FormHandler::Manual::Validation. .SS "Transformers" .IX Subsection "Transformers" See HTML::FormHandler::Manual::InflationDeflation and HTML::FormHandler::Manual::Validation. .SH "AUTHOR" .IX Header "AUTHOR" FormHandler Contributors \- see HTML::FormHandler .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2017 by Gerda Shank. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.