1HTML::FormHandler::ManuUasle:r:ICnofnltHarTtiMibLou:nt:DeFedofrlPmaeHtrailnodnDl(oe3cr)u:m:eMnatnautailo:n:InflationDeflation(3)
2
3
4

NAME

6       HTML::FormHandler::Manual::InflationDeflation - inflation and deflation
7       of field values
8

VERSION

10       version 0.40068
11

SYNOPSIS

13       Manual Index
14
15       How to inflate and deflate field values.
16
17   DESCRIPTION
18       When working with the various ways that data can be transformed, in and
19       out, the meaning of the terms 'inflate' and 'deflate' starts to feel
20       kind of slippery.  The one constant is that values presented in an HTML
21       form must be in a string format, or presented with select elements or
22       checkboxes.
23
24       There are two general types of inflation/deflation provided by
25       FormHandler.  The first, 'standard' type inflates values in order to
26       validate them, and deflates them in order to present them in string
27       format via HTML. The other ('DB') type takes values provided by
28       defaults (usually a DB row, or item, but could also be a field default
29       or an init_object) and munges the values coming in and changes them
30       back going out.
31
32   Standard inflation/deflation
33       The standard type of inflation/deflation is implemented by using some
34       of the following options for inflation:
35
36           inflate_method
37           transform (using 'apply')
38
39       ..and the following options for deflation:
40
41           deflate_method
42           deflation (field attribute)
43
44       When validation starts, the param input will be inflated by the inflate
45       method, allowing validation to be performed on the inflated object.
46
47       When the 'fif' fill-in-form value is returned for HTML generation, the
48       deflation is used to flatten the object, usually into a string format.
49
50   DB inflation/deflation
51       The 'DB' type of inflation/deflation uses 'inflate_default_method' for
52       inflation, and 'deflate_value_method' for deflation. Deflation could
53       also be handled by changing the value in one of the various validation
54       methods.
55
56       This type of inflation/deflation is, logically, just a different way of
57       providing data munging around the defaults (item/init_object/default)
58       and 'value' output.  The same effect could be achieved by performing a
59       transformation outside of FormHandler - if you were handling the
60       database updates yourself. Since the DBIC model enables automatic
61       database updates, this kind of inflation/deflation makes that easier.
62
63       One circumstance in which this type of inflation/deflation is useful is
64       when there's a single field in the database row object which you want
65       to expand into a compound field in the form.
66
67   Attributes used in deflation/inflation
68       Inflation methods
69
70       The field 'input' comes from the params that are passed in from the
71       submission of the form, so the input will always be in string format if
72       it comes from an HTTP request. It's also possible to pass in params in
73       other formats, of course.  Or the params could be pre-processed before
74       passing in to FormHandler.
75
76       You should not normally be changing the 'input' attribute of a field.
77       If you want the changed field value to be used when re-presenting the
78       form, such as when you're adopting a standard format for the field, you
79       should set "fif_from_value => 1".
80
81       There are three options for standard inflation, or transforming the
82       field's 'input' to the field's 'value':
83
84       inflate_method
85           Provide a method on the field which inflates the field 'input'
86           (from params):
87
88              has_field 'futility' => ( inflate_method => \&inflate_field );
89              sub inflate_field {
90                  my ( $self, $value ) = @_;
91                  ....
92                  return $value;
93              }
94
95       transform
96           In a sequence of 'apply' actions, changes the format of the 'value'
97           that is being validated. This might be useful if there are some
98           validations that work on one format of the value, and some that
99           work on another.
100
101       set the value in validation methods
102           In a validate method, you can change the format of the value, with
103           $field->value(...);
104
105       Deflation methods
106
107       deflate_method
108           Most general purpose deflation method. Provide a coderef which is a
109           method on the field:
110
111              has_field => 'foo' => ( deflate_method => \&deflate_foo );
112              sub deflate_foo {
113                  my ( $self, $value ) = @_;  # $self is the 'foo' field
114                  <perform conversion>
115                  return $value;
116              }
117
118       deflation
119           This is a coderef that performs deflation.
120
121              has_field => 'bar' => ( deflation => sub { shift $value; ... return $value } );
122
123       set the value in validation methods
124           Just like for inflation, you can change the value in a validation
125           method; however, it won't be used for fill-in-form unless you set
126           the 'fif_from_value' flag to true.
127
128       fif_from_value
129
130       Normally the fill-in-form value will be the param value that was
131       submitted.  If you want to change the format of the input when re-
132       presenting the form, you can set 'fif_from_value'.
133
134       deflate_to
135
136       Earlier versions of FormHandler provided a 'deflate_to' attribute which
137       allowed the deflation methods to be used for multiple, confusing
138       purposes. This flag has been removed, since it made the process hard to
139       understand and was mixing apples and oranges. The new
140       inflation/deflation methods can handle all of the previous situations.
141

AUTHOR

143       FormHandler Contributors - see HTML::FormHandler
144
146       This software is copyright (c) 2017 by Gerda Shank.
147
148       This is free software; you can redistribute it and/or modify it under
149       the same terms as the Perl 5 programming language system itself.
150
151
152
153perl v5.36.0                  HTML2:0:2F3o-r0m1H-a2n0dler::Manual::InflationDeflation(3)
Impressum