line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu; |
2
|
|
|
|
|
|
|
|
3
|
400
|
|
|
400
|
|
19605128
|
use strict; |
|
400
|
|
|
|
|
633
|
|
|
400
|
|
|
|
|
14582
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
400
|
|
|
400
|
|
175403
|
use Moose; |
|
400
|
|
|
|
|
120049562
|
|
|
400
|
|
|
|
|
2327
|
|
7
|
400
|
|
|
400
|
|
2078047
|
use MooseX::Attribute::FormFuChained; |
|
400
|
|
|
|
|
720
|
|
|
400
|
|
|
|
|
21861
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'HTML::FormFu::Role::Render', |
10
|
|
|
|
|
|
|
'HTML::FormFu::Role::CreateChildren', |
11
|
|
|
|
|
|
|
'HTML::FormFu::Role::GetProcessors', |
12
|
|
|
|
|
|
|
'HTML::FormFu::Role::ContainsElements', |
13
|
|
|
|
|
|
|
'HTML::FormFu::Role::ContainsElementsSharedWithField', |
14
|
|
|
|
|
|
|
'HTML::FormFu::Role::FormAndBlockMethods', |
15
|
|
|
|
|
|
|
'HTML::FormFu::Role::FormAndElementMethods', |
16
|
|
|
|
|
|
|
'HTML::FormFu::Role::FormBlockAndFieldMethods', |
17
|
|
|
|
|
|
|
'HTML::FormFu::Role::NestedHashUtils', |
18
|
|
|
|
|
|
|
'HTML::FormFu::Role::Populate', |
19
|
|
|
|
|
|
|
'HTML::FormFu::Role::CustomRoles'; |
20
|
|
|
|
|
|
|
|
21
|
400
|
|
|
|
|
26970
|
use HTML::FormFu::Attribute qw( |
22
|
|
|
|
|
|
|
mk_attrs |
23
|
|
|
|
|
|
|
mk_attr_accessors |
24
|
|
|
|
|
|
|
mk_output_accessors |
25
|
|
|
|
|
|
|
mk_inherited_accessors |
26
|
|
|
|
|
|
|
mk_inherited_merging_accessors |
27
|
400
|
|
|
400
|
|
160645
|
); |
|
400
|
|
|
|
|
781
|
|
28
|
400
|
|
|
400
|
|
2244
|
use HTML::FormFu::Constants qw( $EMPTY_STR ); |
|
400
|
|
|
|
|
483
|
|
|
400
|
|
|
|
|
29318
|
|
29
|
400
|
|
|
400
|
|
157356
|
use HTML::FormFu::Constraint; |
|
400
|
|
|
|
|
1060
|
|
|
400
|
|
|
|
|
14043
|
|
30
|
400
|
|
|
400
|
|
2461
|
use HTML::FormFu::Exception; |
|
400
|
|
|
|
|
496
|
|
|
400
|
|
|
|
|
7897
|
|
31
|
400
|
|
|
400
|
|
186332
|
use HTML::FormFu::FakeQuery; |
|
400
|
|
|
|
|
699
|
|
|
400
|
|
|
|
|
10545
|
|
32
|
400
|
|
|
400
|
|
123805
|
use HTML::FormFu::Filter; |
|
400
|
|
|
|
|
874
|
|
|
400
|
|
|
|
|
12943
|
|
33
|
400
|
|
|
400
|
|
177924
|
use HTML::FormFu::Inflator; |
|
400
|
|
|
|
|
971
|
|
|
400
|
|
|
|
|
11802
|
|
34
|
400
|
|
|
400
|
|
163199
|
use HTML::FormFu::Localize; |
|
400
|
|
|
|
|
829
|
|
|
400
|
|
|
|
|
26942
|
|
35
|
400
|
|
|
|
|
27338
|
use HTML::FormFu::ObjectUtil qw( |
36
|
|
|
|
|
|
|
form |
37
|
|
|
|
|
|
|
load_config_file load_config_filestem |
38
|
|
|
|
|
|
|
clone stash |
39
|
|
|
|
|
|
|
constraints_from_dbic parent |
40
|
|
|
|
|
|
|
_load_file |
41
|
400
|
|
|
400
|
|
2110
|
); |
|
400
|
|
|
|
|
509
|
|
42
|
400
|
|
|
|
|
25064
|
use HTML::FormFu::Util qw( |
43
|
|
|
|
|
|
|
DEBUG |
44
|
|
|
|
|
|
|
DEBUG_PROCESS |
45
|
|
|
|
|
|
|
DEBUG_CONSTRAINTS |
46
|
|
|
|
|
|
|
debug |
47
|
|
|
|
|
|
|
require_class _get_elements |
48
|
|
|
|
|
|
|
xml_escape split_name |
49
|
|
|
|
|
|
|
_parse_args process_attrs |
50
|
|
|
|
|
|
|
_filter_components |
51
|
400
|
|
|
400
|
|
1632
|
); |
|
400
|
|
|
|
|
490
|
|
52
|
|
|
|
|
|
|
|
53
|
400
|
|
|
400
|
|
1528
|
use Clone (); |
|
400
|
|
|
|
|
472
|
|
|
400
|
|
|
|
|
7817
|
|
54
|
400
|
|
|
400
|
|
1326
|
use List::Util 1.45 qw( first any none uniq ); |
|
400
|
|
|
|
|
6483
|
|
|
400
|
|
|
|
|
23383
|
|
55
|
400
|
|
|
400
|
|
1602
|
use Scalar::Util qw( blessed weaken reftype ); |
|
400
|
|
|
|
|
475
|
|
|
400
|
|
|
|
|
14477
|
|
56
|
400
|
|
|
400
|
|
1426
|
use Carp qw( croak ); |
|
400
|
|
|
|
|
466
|
|
|
400
|
|
|
|
|
25438
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use overload ( |
59
|
|
|
|
|
|
|
'eq' => '_string_equals', |
60
|
|
|
|
|
|
|
'==' => '_object_equals', |
61
|
164
|
|
|
164
|
|
8144
|
'""' => sub { return shift->render }, |
62
|
1
|
|
|
1
|
|
485
|
'bool' => sub {1}, |
63
|
400
|
|
|
|
|
4401
|
'fallback' => 1, |
64
|
400
|
|
|
400
|
|
1653
|
); |
|
400
|
|
|
|
|
517
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__->mk_attr_accessors(qw( id action enctype method )); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
for my $name ( qw( |
69
|
|
|
|
|
|
|
_elements |
70
|
|
|
|
|
|
|
_output_processors |
71
|
|
|
|
|
|
|
_valid_names |
72
|
|
|
|
|
|
|
_plugins |
73
|
|
|
|
|
|
|
_models |
74
|
|
|
|
|
|
|
) ) |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
has $name => ( |
77
|
|
|
|
|
|
|
is => 'rw', |
78
|
|
|
|
|
|
|
default => sub { [] }, |
79
|
|
|
|
|
|
|
lazy => 1, |
80
|
|
|
|
|
|
|
isa => 'ArrayRef', |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
has languages => ( |
85
|
|
|
|
|
|
|
is => 'rw', |
86
|
|
|
|
|
|
|
default => sub { ['en'] }, |
87
|
|
|
|
|
|
|
lazy => 1, |
88
|
|
|
|
|
|
|
isa => 'ArrayRef', |
89
|
|
|
|
|
|
|
traits => ['FormFuChained'], |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
has input => ( |
93
|
|
|
|
|
|
|
is => 'rw', |
94
|
|
|
|
|
|
|
default => sub { {} }, |
95
|
|
|
|
|
|
|
lazy => 1, |
96
|
|
|
|
|
|
|
isa => 'HashRef', |
97
|
|
|
|
|
|
|
traits => ['FormFuChained'], |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has _processed_params => ( |
101
|
|
|
|
|
|
|
is => 'rw', |
102
|
|
|
|
|
|
|
default => sub { {} }, |
103
|
|
|
|
|
|
|
lazy => 1, |
104
|
|
|
|
|
|
|
isa => 'HashRef', |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has form_error_message_class => ( |
108
|
|
|
|
|
|
|
is => 'rw', |
109
|
|
|
|
|
|
|
default => 'form_error_message', |
110
|
|
|
|
|
|
|
lazy => 1, |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
our @MULTIFORM_SHARED = (qw( |
114
|
|
|
|
|
|
|
javascript |
115
|
|
|
|
|
|
|
javascript_src |
116
|
|
|
|
|
|
|
indicator |
117
|
|
|
|
|
|
|
filename |
118
|
|
|
|
|
|
|
query_type |
119
|
|
|
|
|
|
|
force_error_message |
120
|
|
|
|
|
|
|
localize_class |
121
|
|
|
|
|
|
|
tt_module |
122
|
|
|
|
|
|
|
nested_name |
123
|
|
|
|
|
|
|
nested_subscript |
124
|
|
|
|
|
|
|
default_model |
125
|
|
|
|
|
|
|
tmp_upload_dir |
126
|
|
|
|
|
|
|
params_ignore_underscore |
127
|
|
|
|
|
|
|
)); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
for (@MULTIFORM_SHARED) { |
130
|
|
|
|
|
|
|
has $_ => ( |
131
|
|
|
|
|
|
|
is => 'rw', |
132
|
|
|
|
|
|
|
traits => ['FormFuChained'], |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
has submitted => ( is => 'rw', traits => ['FormFuChained'] ); |
137
|
|
|
|
|
|
|
has query => ( is => 'rw', traits => ['FormFuChained'] ); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
has _auto_fieldset => ( is => 'rw' ); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__PACKAGE__->mk_output_accessors(qw( form_error_message )); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
*elements = \&element; |
144
|
|
|
|
|
|
|
*constraints = \&constraint; |
145
|
|
|
|
|
|
|
*filters = \&filter; |
146
|
|
|
|
|
|
|
*deflators = \&deflator; |
147
|
|
|
|
|
|
|
*inflators = \&inflator; |
148
|
|
|
|
|
|
|
*validators = \&validator; |
149
|
|
|
|
|
|
|
*transformers = \&transformer; |
150
|
|
|
|
|
|
|
*output_processors = \&output_processor; |
151
|
|
|
|
|
|
|
*loc = \&localize; |
152
|
|
|
|
|
|
|
*plugins = \&plugin; |
153
|
|
|
|
|
|
|
*add_plugins = \&add_plugin; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
our $build_defaults = { |
156
|
|
|
|
|
|
|
action => '', |
157
|
|
|
|
|
|
|
method => 'post', |
158
|
|
|
|
|
|
|
filename => 'form', |
159
|
|
|
|
|
|
|
render_method => 'string', |
160
|
|
|
|
|
|
|
tt_args => {}, |
161
|
|
|
|
|
|
|
tt_module => 'Template', |
162
|
|
|
|
|
|
|
query_type => 'CGI', |
163
|
|
|
|
|
|
|
default_model => 'DBIC', |
164
|
|
|
|
|
|
|
localize_class => 'HTML::FormFu::I18N', |
165
|
|
|
|
|
|
|
auto_error_message => 'form_%s_%t', |
166
|
|
|
|
|
|
|
error_tag => 'span', |
167
|
|
|
|
|
|
|
}; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub BUILD { |
170
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
$self->populate($build_defaults); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
return; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub auto_fieldset { |
178
|
1011
|
|
|
1011
|
1
|
2384
|
my ( $self, $element_ref ) = @_; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# if there's no arg, just return whether there's an auto_fieldset already |
181
|
1011
|
100
|
|
|
|
25154
|
return $self->_auto_fieldset if !$element_ref; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# if the argument isn't a reference, assume it's just a "1" meaning true, |
184
|
|
|
|
|
|
|
# and use an empty hashref |
185
|
87
|
100
|
|
|
|
283
|
if ( !ref $element_ref ) { |
186
|
46
|
|
|
|
|
78
|
$element_ref = {}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
87
|
|
|
|
|
186
|
$element_ref->{type} = 'Fieldset'; |
190
|
|
|
|
|
|
|
|
191
|
87
|
|
|
|
|
457
|
$self->element($element_ref); |
192
|
|
|
|
|
|
|
|
193
|
87
|
|
|
|
|
1935
|
$self->_auto_fieldset(1); |
194
|
|
|
|
|
|
|
|
195
|
87
|
|
|
|
|
274
|
return $self; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub default_values { |
199
|
7
|
|
|
7
|
1
|
54
|
my ( $self, $default_ref ) = @_; |
200
|
|
|
|
|
|
|
|
201
|
7
|
|
|
|
|
12
|
for my $field ( @{ $self->get_fields } ) { |
|
7
|
|
|
|
|
40
|
|
202
|
18
|
|
|
|
|
68
|
my $name = $field->nested_name; |
203
|
18
|
50
|
|
|
|
35
|
next if !defined $name; |
204
|
18
|
100
|
|
|
|
43
|
next if !exists $default_ref->{$name}; |
205
|
|
|
|
|
|
|
|
206
|
10
|
|
|
|
|
50
|
$field->default( $default_ref->{$name} ); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
7
|
|
|
|
|
20
|
return $self; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub model { |
213
|
21
|
|
|
21
|
1
|
55
|
my ( $self, $model_name ) = @_; |
214
|
|
|
|
|
|
|
|
215
|
21
|
|
66
|
|
|
474
|
$model_name ||= $self->default_model; |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# search models already loaded |
218
|
21
|
|
|
|
|
27
|
for my $model ( @{ $self->_models } ) { |
|
21
|
|
|
|
|
430
|
|
219
|
14
|
50
|
|
|
|
308
|
return $model |
220
|
|
|
|
|
|
|
if $model->type =~ /\Q$model_name\E$/; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# class not found, try require-ing it |
224
|
7
|
100
|
|
|
|
39
|
my $class |
225
|
|
|
|
|
|
|
= $model_name =~ s/^\+// |
226
|
|
|
|
|
|
|
? $model_name |
227
|
|
|
|
|
|
|
: "HTML::FormFu::Model::$model_name"; |
228
|
|
|
|
|
|
|
|
229
|
7
|
|
|
|
|
27
|
require_class($class); |
230
|
|
|
|
|
|
|
|
231
|
7
|
|
|
|
|
244
|
my $model = $class->new( { |
232
|
|
|
|
|
|
|
type => $model_name, |
233
|
|
|
|
|
|
|
parent => $self, |
234
|
|
|
|
|
|
|
} ); |
235
|
|
|
|
|
|
|
|
236
|
7
|
|
|
|
|
22
|
push @{ $self->_models }, $model; |
|
7
|
|
|
|
|
166
|
|
237
|
|
|
|
|
|
|
|
238
|
7
|
|
|
|
|
76
|
return $model; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub process { |
242
|
459
|
|
|
459
|
1
|
57601
|
my ( $self, $query ) = @_; |
243
|
|
|
|
|
|
|
|
244
|
459
|
|
|
|
|
11715
|
$self->input( {} ); |
245
|
459
|
|
|
|
|
10729
|
$self->_processed_params( {} ); |
246
|
459
|
|
|
|
|
10453
|
$self->_valid_names( [] ); |
247
|
|
|
|
|
|
|
|
248
|
459
|
|
|
|
|
2088
|
$self->clear_errors; |
249
|
|
|
|
|
|
|
|
250
|
459
|
|
100
|
|
|
2379
|
$query ||= $self->query; |
251
|
|
|
|
|
|
|
|
252
|
459
|
100
|
100
|
|
|
3590
|
if ( defined $query && !blessed($query) ) { |
253
|
403
|
|
|
|
|
3115
|
$query = HTML::FormFu::FakeQuery->new( $self, $query ); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# save it for further calls to process() |
257
|
459
|
100
|
|
|
|
1884
|
if ($query) { |
258
|
413
|
50
|
|
|
|
1597
|
DEBUG && debug( QUERY => $query ); |
259
|
|
|
|
|
|
|
|
260
|
413
|
|
|
|
|
9878
|
$self->query($query); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# run all elements pre_process() methods |
264
|
459
|
|
|
|
|
620
|
for my $elem ( @{ $self->get_elements } ) { |
|
459
|
|
|
|
|
1836
|
|
265
|
955
|
|
|
|
|
4281
|
$elem->pre_process; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# run all plugins pre_process() methods |
269
|
459
|
|
|
|
|
1509
|
for my $plugin ( @{ $self->get_plugins } ) { |
|
459
|
|
|
|
|
2242
|
|
270
|
0
|
|
|
|
|
0
|
$plugin->pre_process; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
# run all elements process() methods |
274
|
459
|
|
|
|
|
626
|
for my $elem ( @{ $self->get_elements } ) { |
|
459
|
|
|
|
|
1293
|
|
275
|
955
|
|
|
|
|
3657
|
$elem->process; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# run all plugins process() methods |
279
|
459
|
|
|
|
|
1493
|
for my $plugin ( @{ $self->get_plugins } ) { |
|
459
|
|
|
|
|
1531
|
|
280
|
0
|
|
|
|
|
0
|
$plugin->process; |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
459
|
|
|
|
|
697
|
my $submitted; |
284
|
|
|
|
|
|
|
|
285
|
459
|
100
|
|
|
|
1646
|
if ( defined $query ) { |
286
|
413
|
|
|
|
|
633
|
eval { my @params = $query->param }; |
|
413
|
|
|
|
|
2214
|
|
287
|
413
|
50
|
|
|
|
1394
|
croak "Invalid query object: $@" if $@; |
288
|
|
|
|
|
|
|
|
289
|
413
|
|
|
|
|
1489
|
$submitted = $self->_submitted($query); |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
|
292
|
459
|
50
|
|
|
|
1505
|
DEBUG_PROCESS && debug( SUBMITTED => $submitted ); |
293
|
|
|
|
|
|
|
|
294
|
459
|
|
|
|
|
11385
|
$self->submitted($submitted); |
295
|
|
|
|
|
|
|
|
296
|
459
|
100
|
|
|
|
1106
|
if ($submitted) { |
297
|
409
|
|
|
|
|
563
|
my %input; |
298
|
409
|
|
|
|
|
1401
|
my @params = $query->param; |
299
|
|
|
|
|
|
|
|
300
|
409
|
|
|
|
|
756
|
for my $field ( @{ $self->get_fields } ) { |
|
409
|
|
|
|
|
1307
|
|
301
|
1236
|
|
|
|
|
2825
|
my $name = $field->nested_name; |
302
|
|
|
|
|
|
|
|
303
|
1236
|
100
|
|
|
|
3104
|
next if !defined $name; |
304
|
1232
|
100
|
|
3058
|
|
5077
|
next if none { $name eq $_ } @params; |
|
3058
|
|
|
|
|
4041
|
|
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
## CGI wants you to use $query->multi_param($foo). |
307
|
|
|
|
|
|
|
## doing so breaks CGI::Simple. So shoosh it up for now. |
308
|
1011
|
|
|
|
|
2440
|
local $CGI::LIST_CONTEXT_WARN = 0; |
309
|
|
|
|
|
|
|
|
310
|
1011
|
100
|
|
|
|
2848
|
if ( $field->nested ) { |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# call in list context so we know if there's more than 1 value |
313
|
252
|
|
|
|
|
683
|
my @values = $query->param($name); |
314
|
|
|
|
|
|
|
|
315
|
252
|
100
|
|
|
|
568
|
my $value |
316
|
|
|
|
|
|
|
= @values > 1 |
317
|
|
|
|
|
|
|
? \@values |
318
|
|
|
|
|
|
|
: $values[0]; |
319
|
|
|
|
|
|
|
|
320
|
252
|
|
|
|
|
836
|
$self->set_nested_hash_value( \%input, $name, $value ); |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
else { |
323
|
759
|
|
|
|
|
1923
|
my @values = $query->param($name); |
324
|
|
|
|
|
|
|
|
325
|
759
|
100
|
|
|
|
2857
|
$input{$name} |
326
|
|
|
|
|
|
|
= @values > 1 |
327
|
|
|
|
|
|
|
? \@values |
328
|
|
|
|
|
|
|
: $values[0]; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
409
|
50
|
|
|
|
1347
|
DEBUG && debug( INPUT => \%input ); |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
# run all field process_input methods |
335
|
409
|
|
|
|
|
1209
|
for my $field ( @{ $self->get_fields } ) { |
|
409
|
|
|
|
|
1321
|
|
336
|
1236
|
|
|
|
|
3607
|
$field->process_input( \%input ); |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
409
|
|
|
|
|
8964
|
$self->input( \%input ); |
340
|
|
|
|
|
|
|
|
341
|
409
|
|
|
|
|
1262
|
$self->_process_input; |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
# run all plugins post_process methods |
345
|
459
|
|
|
|
|
650
|
for my $elem ( @{ $self->get_elements } ) { |
|
459
|
|
|
|
|
2009
|
|
346
|
955
|
|
|
|
|
4534
|
$elem->post_process; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
459
|
|
|
|
|
1458
|
for my $plugin ( @{ $self->get_plugins } ) { |
|
459
|
|
|
|
|
1584
|
|
350
|
0
|
|
|
|
|
0
|
$plugin->post_process; |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
459
|
|
|
|
|
1177
|
return; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub _submitted { |
357
|
413
|
|
|
413
|
|
578
|
my ( $self, $query ) = @_; |
358
|
|
|
|
|
|
|
|
359
|
413
|
|
|
|
|
9615
|
my $indicator = $self->indicator; |
360
|
413
|
|
|
|
|
559
|
my $code; |
361
|
|
|
|
|
|
|
|
362
|
413
|
100
|
100
|
|
|
2330
|
if ( defined($indicator) && ref $indicator ne 'CODE' ) { |
|
|
100
|
|
|
|
|
|
363
|
7
|
50
|
|
|
|
22
|
DEBUG_PROCESS && debug( INDICATOR => $indicator ); |
364
|
|
|
|
|
|
|
|
365
|
7
|
|
|
7
|
|
27
|
$code = sub { return defined $query->param($indicator) }; |
|
7
|
|
|
|
|
18
|
|
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
elsif ( !defined $indicator ) { |
368
|
|
|
|
|
|
|
my @names = uniq |
369
|
1170
|
|
|
|
|
3680
|
grep {defined} |
370
|
393
|
|
|
|
|
611
|
map { $_->nested_name } @{ $self->get_fields }; |
|
1172
|
|
|
|
|
2611
|
|
|
393
|
|
|
|
|
1425
|
|
371
|
|
|
|
|
|
|
|
372
|
393
|
50
|
|
|
|
1731
|
DEBUG_PROCESS && debug( 'no indicator, checking fields...' => \@names ); |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
$code = sub { |
375
|
393
|
|
|
393
|
|
694
|
grep { defined $query->param($_) } @names; |
|
1147
|
|
|
|
|
2534
|
|
376
|
393
|
|
|
|
|
2489
|
}; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
else { |
379
|
13
|
|
|
|
|
24
|
$code = $indicator; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
413
|
|
|
|
|
1376
|
return $code->( $self, $query ); |
383
|
|
|
|
|
|
|
} |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
sub _process_input { |
386
|
409
|
|
|
409
|
|
618
|
my ($self) = @_; |
387
|
|
|
|
|
|
|
|
388
|
409
|
|
|
|
|
1163
|
$self->_build_params; |
389
|
|
|
|
|
|
|
|
390
|
409
|
|
|
|
|
1204
|
$self->_process_file_uploads; |
391
|
|
|
|
|
|
|
|
392
|
409
|
|
|
|
|
1140
|
$self->_filter_input; |
393
|
409
|
|
|
|
|
1170
|
$self->_constrain_input; |
394
|
409
|
100
|
|
|
|
458
|
$self->_inflate_input if !@{ $self->get_errors }; |
|
409
|
|
|
|
|
1803
|
|
395
|
409
|
100
|
|
|
|
496
|
$self->_validate_input if !@{ $self->get_errors }; |
|
409
|
|
|
|
|
1443
|
|
396
|
409
|
100
|
|
|
|
1323
|
$self->_transform_input if !@{ $self->get_errors }; |
|
409
|
|
|
|
|
1121
|
|
397
|
|
|
|
|
|
|
|
398
|
409
|
|
|
|
|
1229
|
$self->_build_valid_names; |
399
|
|
|
|
|
|
|
|
400
|
409
|
|
|
|
|
846
|
return; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
sub _build_params { |
404
|
409
|
|
|
409
|
|
579
|
my ($self) = @_; |
405
|
|
|
|
|
|
|
|
406
|
409
|
|
|
|
|
9587
|
my $input = $self->input; |
407
|
409
|
|
|
|
|
569
|
my %params; |
408
|
|
|
|
|
|
|
|
409
|
409
|
|
|
|
|
554
|
for my $field ( @{ $self->get_fields } ) { |
|
409
|
|
|
|
|
1313
|
|
410
|
1236
|
|
|
|
|
2884
|
my $name = $field->nested_name; |
411
|
|
|
|
|
|
|
|
412
|
1236
|
100
|
|
|
|
2499
|
next if !defined $name; |
413
|
1232
|
100
|
|
|
|
2437
|
next if exists $params{$name}; |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
next |
416
|
1211
|
100
|
66
|
|
|
23227
|
if !$self->nested_hash_key_exists( $self->input, $name ) |
417
|
|
|
|
|
|
|
&& !$field->default_empty_value; |
418
|
|
|
|
|
|
|
|
419
|
1053
|
|
|
|
|
20732
|
my $input = $self->get_nested_hash_value( $self->input, $name ); |
420
|
|
|
|
|
|
|
|
421
|
1053
|
100
|
100
|
|
|
5267
|
if ( ref $input eq 'ARRAY' ) { |
|
|
100
|
|
|
|
|
|
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
# can't clone upload filehandles |
424
|
|
|
|
|
|
|
# so create new arrayref of values |
425
|
63
|
|
|
|
|
163
|
$input = [@$input]; |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
elsif ( !defined $input && $field->default_empty_value ) { |
428
|
3
|
|
|
|
|
6
|
$input = ''; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
1053
|
|
|
|
|
3009
|
$self->set_nested_hash_value( \%params, $name, $input, $name ); |
432
|
|
|
|
|
|
|
} |
433
|
|
|
|
|
|
|
|
434
|
409
|
|
|
|
|
9503
|
$self->_processed_params( \%params ); |
435
|
|
|
|
|
|
|
|
436
|
409
|
50
|
|
|
|
1118
|
DEBUG_PROCESS && debug( 'PROCESSED PARAMS' => \%params ); |
437
|
|
|
|
|
|
|
|
438
|
409
|
|
|
|
|
708
|
return; |
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
sub _process_file_uploads { |
442
|
409
|
|
|
409
|
|
631
|
my ($self) = @_; |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
my @names = uniq |
445
|
31
|
|
|
|
|
87
|
grep {defined} |
446
|
31
|
|
|
|
|
68
|
map { $_->nested_name } |
447
|
409
|
|
|
|
|
2596
|
grep { $_->isa('HTML::FormFu::Element::File') } @{ $self->get_fields }; |
|
1236
|
|
|
|
|
6509
|
|
|
409
|
|
|
|
|
1315
|
|
448
|
|
|
|
|
|
|
|
449
|
409
|
100
|
|
|
|
1314
|
if (@names) { |
450
|
14
|
|
|
|
|
301
|
my $query_class = $self->query_type; |
451
|
14
|
50
|
|
|
|
49
|
if ( $query_class !~ /^\+/ ) { |
452
|
14
|
|
|
|
|
35
|
$query_class = "HTML::FormFu::QueryType::$query_class"; |
453
|
|
|
|
|
|
|
} |
454
|
14
|
|
|
|
|
43
|
require_class($query_class); |
455
|
|
|
|
|
|
|
|
456
|
14
|
|
|
|
|
375
|
my $params = $self->_processed_params; |
457
|
14
|
|
|
|
|
295
|
my $input = $self->input; |
458
|
|
|
|
|
|
|
|
459
|
14
|
|
|
|
|
34
|
for my $name (@names) { |
460
|
29
|
100
|
|
|
|
95
|
next if !$self->nested_hash_key_exists( $input, $name ); |
461
|
|
|
|
|
|
|
|
462
|
26
|
|
|
|
|
89
|
my $values = $query_class->parse_uploads( $self, $name ); |
463
|
|
|
|
|
|
|
|
464
|
26
|
|
|
|
|
83
|
$self->set_nested_hash_value( $params, $name, $values ); |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
409
|
|
|
|
|
935
|
return; |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
sub _filter_input { |
472
|
409
|
|
|
409
|
|
1186
|
my ($self) = @_; |
473
|
|
|
|
|
|
|
|
474
|
409
|
|
|
|
|
9370
|
my $params = $self->_processed_params; |
475
|
|
|
|
|
|
|
|
476
|
409
|
|
|
|
|
991
|
for my $filter ( @{ $self->get_filters } ) { |
|
409
|
|
|
|
|
2078
|
|
477
|
62
|
|
|
|
|
326
|
my $name = $filter->nested_name; |
478
|
|
|
|
|
|
|
|
479
|
62
|
50
|
|
|
|
158
|
next if !defined $name; |
480
|
62
|
100
|
|
|
|
191
|
next if !$self->nested_hash_key_exists( $params, $name ); |
481
|
|
|
|
|
|
|
|
482
|
59
|
|
|
|
|
364
|
$filter->process( $self, $params ); |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
|
485
|
409
|
|
|
|
|
685
|
return; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
sub _constrain_input { |
489
|
409
|
|
|
409
|
|
578
|
my ($self) = @_; |
490
|
|
|
|
|
|
|
|
491
|
409
|
|
|
|
|
9045
|
my $params = $self->_processed_params; |
492
|
|
|
|
|
|
|
|
493
|
409
|
|
|
|
|
604
|
for my $constraint ( @{ $self->get_constraints } ) { |
|
409
|
|
|
|
|
3246
|
|
494
|
|
|
|
|
|
|
|
495
|
572
|
50
|
|
|
|
1186
|
DEBUG_CONSTRAINTS && debug( |
496
|
|
|
|
|
|
|
'FIELD NAME' => $constraint->field->nested_name, |
497
|
|
|
|
|
|
|
'CONSTRAINT TYPE' => $constraint->type, |
498
|
|
|
|
|
|
|
); |
499
|
|
|
|
|
|
|
|
500
|
572
|
|
|
|
|
2317
|
$constraint->pre_process; |
501
|
|
|
|
|
|
|
|
502
|
572
|
|
|
|
|
699
|
my @errors = eval { $constraint->process($params) }; |
|
572
|
|
|
|
|
1639
|
|
503
|
|
|
|
|
|
|
|
504
|
572
|
50
|
|
|
|
1250
|
DEBUG_CONSTRAINTS && debug( ERRORS => \@errors ); |
505
|
572
|
50
|
|
|
|
1126
|
DEBUG_CONSTRAINTS && debug( '$@' => $@ ); |
506
|
|
|
|
|
|
|
|
507
|
572
|
50
|
33
|
|
|
2541
|
if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Constraint') ) { |
|
|
50
|
|
|
|
|
|
508
|
0
|
|
|
|
|
0
|
push @errors, $@; |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
elsif ($@) { |
511
|
0
|
|
|
|
|
0
|
push @errors, HTML::FormFu::Exception::Constraint->new; |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
|
514
|
572
|
|
|
|
|
1342
|
for my $error (@errors) { |
515
|
196
|
100
|
|
|
|
1377
|
if ( !$error->parent ) { |
516
|
128
|
|
|
|
|
594
|
$error->parent( $constraint->parent ); |
517
|
|
|
|
|
|
|
} |
518
|
196
|
50
|
|
|
|
747
|
if ( !$error->constraint ) { |
519
|
196
|
|
|
|
|
539
|
$error->constraint($constraint); |
520
|
|
|
|
|
|
|
} |
521
|
|
|
|
|
|
|
|
522
|
196
|
|
|
|
|
486
|
$error->parent->add_error($error); |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
|
526
|
409
|
|
|
|
|
1579
|
return; |
527
|
|
|
|
|
|
|
} |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
sub _inflate_input { |
530
|
282
|
|
|
282
|
|
453
|
my ($self) = @_; |
531
|
|
|
|
|
|
|
|
532
|
282
|
|
|
|
|
6573
|
my $params = $self->_processed_params; |
533
|
|
|
|
|
|
|
|
534
|
282
|
|
|
|
|
1015
|
for my $inflator ( @{ $self->get_inflators } ) { |
|
282
|
|
|
|
|
1209
|
|
535
|
27
|
|
|
|
|
225
|
my $name = $inflator->nested_name; |
536
|
|
|
|
|
|
|
|
537
|
27
|
50
|
|
|
|
97
|
next if !defined $name; |
538
|
27
|
100
|
|
|
|
210
|
next if !$self->nested_hash_key_exists( $params, $name ); |
539
|
26
|
50
|
|
0
|
|
123
|
next if any {defined} @{ $inflator->parent->get_errors }; |
|
0
|
|
|
|
|
0
|
|
|
26
|
|
|
|
|
93
|
|
540
|
|
|
|
|
|
|
|
541
|
26
|
|
|
|
|
153
|
my $value = $self->get_nested_hash_value( $params, $name ); |
542
|
|
|
|
|
|
|
|
543
|
26
|
|
|
|
|
52
|
my @errors; |
544
|
|
|
|
|
|
|
|
545
|
26
|
|
|
|
|
45
|
( $value, @errors ) = eval { $inflator->process($value) }; |
|
26
|
|
|
|
|
183
|
|
546
|
|
|
|
|
|
|
|
547
|
26
|
50
|
33
|
|
|
177
|
if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Inflator') ) { |
|
|
50
|
|
|
|
|
|
548
|
0
|
|
|
|
|
0
|
push @errors, $@; |
549
|
|
|
|
|
|
|
} |
550
|
|
|
|
|
|
|
elsif ($@) { |
551
|
0
|
|
|
|
|
0
|
push @errors, HTML::FormFu::Exception::Inflator->new; |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
|
554
|
26
|
|
|
|
|
62
|
for my $error (@errors) { |
555
|
3
|
50
|
|
|
|
19
|
$error->parent( $inflator->parent ) if !$error->parent; |
556
|
3
|
50
|
|
|
|
13
|
$error->inflator($inflator) if !$error->inflator; |
557
|
|
|
|
|
|
|
|
558
|
3
|
|
|
|
|
10
|
$error->parent->add_error($error); |
559
|
|
|
|
|
|
|
} |
560
|
|
|
|
|
|
|
|
561
|
26
|
|
|
|
|
99
|
$self->set_nested_hash_value( $params, $name, $value ); |
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
|
564
|
282
|
|
|
|
|
981
|
return; |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
sub _validate_input { |
568
|
279
|
|
|
279
|
|
447
|
my ($self) = @_; |
569
|
|
|
|
|
|
|
|
570
|
279
|
|
|
|
|
6580
|
my $params = $self->_processed_params; |
571
|
|
|
|
|
|
|
|
572
|
279
|
|
|
|
|
448
|
for my $validator ( @{ $self->get_validators } ) { |
|
279
|
|
|
|
|
1142
|
|
573
|
8
|
|
|
|
|
35
|
my $name = $validator->nested_name; |
574
|
|
|
|
|
|
|
|
575
|
8
|
50
|
|
|
|
17
|
next if !defined $name; |
576
|
8
|
50
|
|
|
|
23
|
next if !$self->nested_hash_key_exists( $params, $name ); |
577
|
8
|
50
|
|
0
|
|
26
|
next if any {defined} @{ $validator->parent->get_errors }; |
|
0
|
|
|
|
|
0
|
|
|
8
|
|
|
|
|
19
|
|
578
|
|
|
|
|
|
|
|
579
|
8
|
|
|
|
|
26
|
my @errors = eval { $validator->process($params) }; |
|
8
|
|
|
|
|
32
|
|
580
|
|
|
|
|
|
|
|
581
|
8
|
50
|
33
|
|
|
42
|
if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Validator') ) { |
|
|
50
|
|
|
|
|
|
582
|
0
|
|
|
|
|
0
|
push @errors, $@; |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
elsif ($@) { |
585
|
0
|
|
|
|
|
0
|
push @errors, HTML::FormFu::Exception::Validator->new; |
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
|
588
|
8
|
|
|
|
|
17
|
for my $error (@errors) { |
589
|
1
|
50
|
|
|
|
7
|
$error->parent( $validator->parent ) if !$error->parent; |
590
|
1
|
50
|
|
|
|
4
|
$error->validator($validator) if !$error->validator; |
591
|
|
|
|
|
|
|
|
592
|
1
|
|
|
|
|
3
|
$error->parent->add_error($error); |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
} |
595
|
|
|
|
|
|
|
|
596
|
279
|
|
|
|
|
788
|
return; |
597
|
|
|
|
|
|
|
} |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
sub _transform_input { |
600
|
278
|
|
|
278
|
|
949
|
my ($self) = @_; |
601
|
|
|
|
|
|
|
|
602
|
278
|
|
|
|
|
6107
|
my $params = $self->_processed_params; |
603
|
|
|
|
|
|
|
|
604
|
278
|
|
|
|
|
439
|
for my $transformer ( @{ $self->get_transformers } ) { |
|
278
|
|
|
|
|
1333
|
|
605
|
5
|
|
|
|
|
20
|
my $name = $transformer->nested_name; |
606
|
|
|
|
|
|
|
|
607
|
5
|
50
|
|
|
|
14
|
next if !defined $name; |
608
|
5
|
50
|
|
|
|
15
|
next if !$self->nested_hash_key_exists( $params, $name ); |
609
|
5
|
50
|
|
0
|
|
16
|
next if any {defined} @{ $transformer->parent->get_errors }; |
|
0
|
|
|
|
|
0
|
|
|
5
|
|
|
|
|
292
|
|
610
|
|
|
|
|
|
|
|
611
|
5
|
|
|
|
|
21
|
my $value = $self->get_nested_hash_value( $params, $name ); |
612
|
|
|
|
|
|
|
|
613
|
5
|
|
|
|
|
5
|
my (@errors) = eval { $transformer->process( $value, $params ) }; |
|
5
|
|
|
|
|
19
|
|
614
|
|
|
|
|
|
|
|
615
|
5
|
50
|
33
|
|
|
25
|
if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Transformer') ) { |
|
|
50
|
|
|
|
|
|
616
|
0
|
|
|
|
|
0
|
push @errors, $@; |
617
|
|
|
|
|
|
|
} |
618
|
|
|
|
|
|
|
elsif ($@) { |
619
|
0
|
|
|
|
|
0
|
push @errors, HTML::FormFu::Exception::Transformer->new; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
5
|
|
|
|
|
10
|
for my $error (@errors) { |
623
|
0
|
0
|
|
|
|
0
|
$error->parent( $transformer->parent ) if !$error->parent; |
624
|
0
|
0
|
|
|
|
0
|
$error->transformer($transformer) if !$error->transformer; |
625
|
|
|
|
|
|
|
|
626
|
0
|
|
|
|
|
0
|
$error->parent->add_error($error); |
627
|
|
|
|
|
|
|
} |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
|
630
|
278
|
|
|
|
|
412
|
return; |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
sub _build_valid_names { |
634
|
409
|
|
|
409
|
|
873
|
my ($self) = @_; |
635
|
|
|
|
|
|
|
|
636
|
409
|
|
|
|
|
9239
|
my $params = $self->_processed_params; |
637
|
409
|
|
|
|
|
10367
|
my $skip_private = $self->params_ignore_underscore; |
638
|
409
|
|
|
|
|
1519
|
my @errors = $self->has_errors; |
639
|
409
|
|
|
|
|
1130
|
my @names; |
640
|
|
|
|
|
|
|
my %non_param; |
641
|
|
|
|
|
|
|
|
642
|
409
|
|
|
|
|
548
|
for my $field ( @{ $self->get_fields } ) { |
|
409
|
|
|
|
|
1828
|
|
643
|
1236
|
|
|
|
|
2793
|
my $name = $field->nested_name; |
644
|
|
|
|
|
|
|
|
645
|
1236
|
100
|
|
|
|
2479
|
next if !defined $name; |
646
|
1232
|
100
|
100
|
|
|
2668
|
next if $skip_private && $field->name =~ /^_/; |
647
|
|
|
|
|
|
|
|
648
|
1231
|
100
|
|
|
|
30483
|
if ( $field->non_param ) { |
|
|
100
|
|
|
|
|
|
649
|
6
|
|
|
|
|
16
|
$non_param{$name} = 1; |
650
|
|
|
|
|
|
|
} |
651
|
|
|
|
|
|
|
elsif ( $self->nested_hash_key_exists( $params, $name ) ) { |
652
|
1047
|
|
|
|
|
1995
|
push @names, $name; |
653
|
|
|
|
|
|
|
} |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
push @names, uniq |
657
|
909
|
|
|
|
|
4172
|
grep { ref $params->{$_} ne 'HASH' } |
658
|
910
|
|
100
|
|
|
1978
|
grep { !( $skip_private && /^_/ ) } |
659
|
409
|
|
|
|
|
1504
|
grep { !exists $non_param{$_} } |
|
913
|
|
|
|
|
1465
|
|
660
|
|
|
|
|
|
|
keys %$params; |
661
|
|
|
|
|
|
|
|
662
|
409
|
|
|
|
|
732
|
my %valid; |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
CHECK: |
665
|
409
|
|
|
|
|
729
|
for my $name (@names) { |
666
|
1886
|
|
|
|
|
1633
|
for my $error (@errors) { |
667
|
780
|
100
|
|
|
|
1713
|
next CHECK if $name eq $error; |
668
|
|
|
|
|
|
|
} |
669
|
1628
|
|
|
|
|
1864
|
$valid{$name}++; |
670
|
|
|
|
|
|
|
} |
671
|
409
|
|
|
|
|
1591
|
my @valid = keys %valid; |
672
|
|
|
|
|
|
|
|
673
|
409
|
|
|
|
|
10144
|
$self->_valid_names( \@valid ); |
674
|
|
|
|
|
|
|
|
675
|
409
|
|
|
|
|
1303
|
return; |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
sub _hash_keys { |
679
|
4
|
|
|
4
|
|
876
|
my ( $hash, $subscript ) = @_; |
680
|
4
|
|
|
|
|
4
|
my @names; |
681
|
|
|
|
|
|
|
|
682
|
4
|
|
|
|
|
8
|
for my $key ( keys %$hash ) { |
683
|
10
|
100
|
|
|
|
18
|
if ( ref $hash->{$key} eq 'HASH' ) { |
|
|
100
|
|
|
|
|
|
684
|
|
|
|
|
|
|
push @names, |
685
|
4
|
100
|
|
|
|
12
|
map { $subscript ? "${key}[${_}]" : "$key.$_" } |
686
|
2
|
|
|
|
|
7
|
_hash_keys( $hash->{$key}, $subscript ); |
687
|
|
|
|
|
|
|
} |
688
|
|
|
|
|
|
|
elsif ( ref $hash->{$key} eq 'ARRAY' ) { |
689
|
|
|
|
|
|
|
push @names, |
690
|
4
|
100
|
|
|
|
12
|
map { $subscript ? "${key}[${_}]" : "$key.$_" } |
691
|
2
|
|
|
|
|
4
|
_array_indices( $hash->{$key}, $subscript ); |
692
|
|
|
|
|
|
|
} |
693
|
|
|
|
|
|
|
else { |
694
|
6
|
|
|
|
|
10
|
push @names, $key; |
695
|
|
|
|
|
|
|
} |
696
|
|
|
|
|
|
|
} |
697
|
|
|
|
|
|
|
|
698
|
4
|
|
|
|
|
12
|
return @names; |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
sub _array_indices { |
702
|
2
|
|
|
2
|
|
2
|
my ( $array, $subscript ) = @_; |
703
|
|
|
|
|
|
|
|
704
|
2
|
|
|
|
|
3
|
my @names; |
705
|
|
|
|
|
|
|
|
706
|
2
|
|
|
|
|
1
|
for my $i ( 0 .. $#{$array} ) { |
|
2
|
|
|
|
|
5
|
|
707
|
4
|
50
|
|
|
|
10
|
if ( ref $array->[$i] eq 'HASH' ) { |
|
|
50
|
|
|
|
|
|
708
|
|
|
|
|
|
|
push @names, |
709
|
0
|
0
|
|
|
|
0
|
map { $subscript ? "${i}[${_}]" : "$i.$_" } |
|
0
|
|
|
|
|
0
|
|
710
|
|
|
|
|
|
|
_hash_keys( $array->[$i], $subscript ); |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
elsif ( ref $array->[$i] eq 'ARRAY' ) { |
713
|
|
|
|
|
|
|
push @names, |
714
|
0
|
0
|
|
|
|
0
|
map { $subscript ? "${i}[${_}]" : "$i.$_" } |
|
0
|
|
|
|
|
0
|
|
715
|
|
|
|
|
|
|
_array_indices( $array->[$i], $subscript ); |
716
|
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
else { |
718
|
4
|
|
|
|
|
4
|
push @names, $i; |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
2
|
|
|
|
|
3
|
return @names; |
723
|
|
|
|
|
|
|
} |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
sub submitted_and_valid { |
726
|
116
|
|
|
116
|
1
|
412
|
my ($self) = @_; |
727
|
|
|
|
|
|
|
|
728
|
116
|
|
100
|
|
|
2466
|
return $self->submitted && !$self->has_errors; |
729
|
|
|
|
|
|
|
} |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
sub params { |
732
|
79
|
|
|
79
|
1
|
3521
|
my ($self) = @_; |
733
|
|
|
|
|
|
|
|
734
|
79
|
50
|
|
|
|
2089
|
return {} if !$self->submitted; |
735
|
|
|
|
|
|
|
|
736
|
79
|
|
|
|
|
255
|
my @names = $self->valid; |
737
|
79
|
|
|
|
|
119
|
my %params; |
738
|
|
|
|
|
|
|
|
739
|
79
|
|
|
|
|
141
|
for my $name (@names) { |
740
|
191
|
|
|
|
|
366
|
my @values = $self->param($name); |
741
|
|
|
|
|
|
|
|
742
|
191
|
100
|
|
|
|
370
|
if ( @values > 1 ) { |
743
|
15
|
|
|
|
|
47
|
$self->set_nested_hash_value( \%params, $name, \@values ); |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
else { |
746
|
176
|
|
|
|
|
461
|
$self->set_nested_hash_value( \%params, $name, $values[0] ); |
747
|
|
|
|
|
|
|
} |
748
|
|
|
|
|
|
|
} |
749
|
|
|
|
|
|
|
|
750
|
79
|
|
|
|
|
466
|
return \%params; |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
sub param { |
754
|
339
|
|
|
339
|
1
|
5811
|
my ( $self, $name ) = @_; |
755
|
|
|
|
|
|
|
|
756
|
339
|
50
|
|
|
|
798
|
croak 'param method is readonly' if @_ > 2; |
757
|
|
|
|
|
|
|
|
758
|
339
|
50
|
|
|
|
7728
|
return if !$self->submitted; |
759
|
|
|
|
|
|
|
|
760
|
339
|
100
|
|
|
|
702
|
if ( @_ == 2 ) { |
761
|
334
|
100
|
|
|
|
618
|
return if !$self->valid($name); |
762
|
|
|
|
|
|
|
|
763
|
315
|
|
|
|
|
7577
|
my $value |
764
|
|
|
|
|
|
|
= $self->get_nested_hash_value( $self->_processed_params, $name ); |
765
|
|
|
|
|
|
|
|
766
|
315
|
100
|
|
|
|
767
|
return if !defined $value; |
767
|
|
|
|
|
|
|
|
768
|
307
|
100
|
|
|
|
628
|
if ( ref $value eq 'ARRAY' ) { |
769
|
22
|
100
|
|
|
|
107
|
return wantarray ? @$value : $value->[0]; |
770
|
|
|
|
|
|
|
} |
771
|
|
|
|
|
|
|
else { |
772
|
285
|
|
|
|
|
1053
|
return $value; |
773
|
|
|
|
|
|
|
} |
774
|
|
|
|
|
|
|
} |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
# return a list of valid names, if no $name arg |
777
|
5
|
|
|
|
|
11
|
return $self->valid; |
778
|
|
|
|
|
|
|
} |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
sub param_value { |
781
|
38
|
|
|
38
|
1
|
93
|
my ( $self, $name ) = @_; |
782
|
|
|
|
|
|
|
|
783
|
38
|
50
|
|
|
|
128
|
croak 'name parameter required' if @_ != 2; |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
return undef ## no critic (ProhibitExplicitReturnUndef); |
786
|
38
|
100
|
|
|
|
105
|
if !$self->valid($name); |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
# this is guaranteed to always return a single value |
789
|
|
|
|
|
|
|
|
790
|
37
|
|
|
|
|
866
|
my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); |
791
|
|
|
|
|
|
|
|
792
|
37
|
100
|
|
|
|
224
|
return ref $value eq 'ARRAY' |
793
|
|
|
|
|
|
|
? $value->[0] |
794
|
|
|
|
|
|
|
: $value; |
795
|
|
|
|
|
|
|
} |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
sub param_array { |
798
|
7
|
|
|
7
|
1
|
16
|
my ( $self, $name ) = @_; |
799
|
|
|
|
|
|
|
|
800
|
7
|
50
|
|
|
|
19
|
croak 'name parameter required' if @_ != 2; |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
# guaranteed to always return an arrayref |
803
|
|
|
|
|
|
|
|
804
|
7
|
100
|
|
|
|
17
|
return [] if !$self->valid($name); |
805
|
|
|
|
|
|
|
|
806
|
6
|
|
|
|
|
128
|
my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); |
807
|
|
|
|
|
|
|
|
808
|
6
|
50
|
|
|
|
16
|
return [] if !defined $value; |
809
|
|
|
|
|
|
|
|
810
|
6
|
100
|
|
|
|
39
|
return ref $value eq 'ARRAY' |
811
|
|
|
|
|
|
|
? $value |
812
|
|
|
|
|
|
|
: [$value]; |
813
|
|
|
|
|
|
|
} |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
sub param_list { |
816
|
3
|
|
|
3
|
1
|
4
|
my ( $self, $name ) = @_; |
817
|
|
|
|
|
|
|
|
818
|
3
|
50
|
|
|
|
8
|
croak 'name parameter required' if @_ != 2; |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
# guaranteed to always return an arrayref |
821
|
|
|
|
|
|
|
|
822
|
3
|
100
|
|
|
|
7
|
return if !$self->valid($name); |
823
|
|
|
|
|
|
|
|
824
|
2
|
|
|
|
|
43
|
my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); |
825
|
|
|
|
|
|
|
|
826
|
2
|
50
|
|
|
|
5
|
return if !defined $value; |
827
|
|
|
|
|
|
|
|
828
|
2
|
100
|
|
|
|
13
|
return ref $value eq 'ARRAY' |
829
|
|
|
|
|
|
|
? @$value |
830
|
|
|
|
|
|
|
: $value; |
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
sub valid { |
834
|
992
|
|
|
992
|
1
|
15696
|
my $self = shift; |
835
|
|
|
|
|
|
|
|
836
|
992
|
50
|
|
|
|
22373
|
return if !$self->submitted; |
837
|
|
|
|
|
|
|
|
838
|
992
|
|
|
|
|
957
|
my @valid = @{ $self->_valid_names }; |
|
992
|
|
|
|
|
19995
|
|
839
|
|
|
|
|
|
|
|
840
|
992
|
100
|
|
|
|
1906
|
if (@_) { |
841
|
814
|
|
|
|
|
966
|
my $name = shift; |
842
|
|
|
|
|
|
|
|
843
|
814
|
100
|
|
1655
|
|
3911
|
return 1 if any { $name eq $_ } @valid; |
|
1655
|
|
|
|
|
5140
|
|
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
# not found - see if it's the name of a nested block |
846
|
104
|
|
|
|
|
281
|
my $parent; |
847
|
|
|
|
|
|
|
|
848
|
104
|
50
|
33
|
|
|
2238
|
if ( defined $self->nested_name && $self->nested_name eq $name ) { |
849
|
0
|
|
|
|
|
0
|
$parent = $self; |
850
|
|
|
|
|
|
|
} |
851
|
|
|
|
|
|
|
else { |
852
|
|
|
|
|
|
|
($parent) |
853
|
100
|
|
|
100
|
|
701
|
= first { $_->isa('HTML::FormFu::Element::Block') } |
854
|
104
|
|
|
|
|
312
|
@{ $self->get_all_elements( { nested_name => $name, } ) }; |
|
104
|
|
|
|
|
526
|
|
855
|
|
|
|
|
|
|
} |
856
|
|
|
|
|
|
|
|
857
|
104
|
100
|
|
|
|
476
|
if ( defined $parent ) { |
858
|
3
|
|
|
3
|
|
6
|
my $fail = any {defined} |
859
|
5
|
|
|
|
|
19
|
map { @{ $_->get_errors } } @{ $parent->get_fields }; |
|
16
|
|
|
|
|
11
|
|
|
16
|
|
|
|
|
34
|
|
|
5
|
|
|
|
|
15
|
|
860
|
|
|
|
|
|
|
|
861
|
5
|
100
|
|
|
|
27
|
return 1 if !$fail; |
862
|
|
|
|
|
|
|
} |
863
|
|
|
|
|
|
|
|
864
|
102
|
|
|
|
|
458
|
return; |
865
|
|
|
|
|
|
|
} |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
# return a list of valid names, if no $name arg |
868
|
178
|
|
|
|
|
488
|
return @valid; |
869
|
|
|
|
|
|
|
} |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
sub has_errors { |
872
|
904
|
|
|
904
|
1
|
2476
|
my $self = shift; |
873
|
|
|
|
|
|
|
|
874
|
904
|
100
|
|
|
|
19330
|
return if !$self->submitted; |
875
|
|
|
|
|
|
|
|
876
|
371
|
|
|
|
|
841
|
my @names = map { $_->nested_name } |
877
|
2515
|
|
|
|
|
2029
|
grep { @{ $_->get_errors } } |
|
2515
|
|
|
|
|
4708
|
|
878
|
760
|
|
|
|
|
1005
|
grep { defined $_->nested_name } @{ $self->get_fields }; |
|
2521
|
|
|
|
|
4993
|
|
|
760
|
|
|
|
|
2110
|
|
879
|
|
|
|
|
|
|
|
880
|
760
|
100
|
|
|
|
2709
|
if (@_) { |
881
|
142
|
|
|
|
|
212
|
my $name = shift; |
882
|
142
|
100
|
|
112
|
|
785
|
return 1 if any {/\Q$name/} @names; |
|
112
|
|
|
|
|
1985
|
|
883
|
89
|
|
|
|
|
508
|
return; |
884
|
|
|
|
|
|
|
} |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
# return list of names with errors, if no $name arg |
887
|
618
|
|
|
|
|
2130
|
return @names; |
888
|
|
|
|
|
|
|
} |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
sub add_valid { |
891
|
4
|
|
|
4
|
1
|
11
|
my ( $self, $key, $value ) = @_; |
892
|
|
|
|
|
|
|
|
893
|
4
|
50
|
|
|
|
11
|
croak 'add_valid requires arguments ($key, $value)' if @_ != 3; |
894
|
|
|
|
|
|
|
|
895
|
4
|
|
|
|
|
103
|
$self->set_nested_hash_value( $self->input, $key, $value ); |
896
|
|
|
|
|
|
|
|
897
|
4
|
|
|
|
|
87
|
$self->set_nested_hash_value( $self->_processed_params, $key, $value ); |
898
|
|
|
|
|
|
|
|
899
|
4
|
50
|
|
7
|
|
13
|
if ( none { $_ eq $key } @{ $self->_valid_names } ) { |
|
7
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
94
|
|
900
|
4
|
|
|
|
|
6
|
push @{ $self->_valid_names }, $key; |
|
4
|
|
|
|
|
92
|
|
901
|
|
|
|
|
|
|
} |
902
|
|
|
|
|
|
|
|
903
|
4
|
|
|
|
|
11
|
return $value; |
904
|
|
|
|
|
|
|
} |
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
sub _single_plugin { |
907
|
1
|
|
|
1
|
|
2
|
my ( $self, $arg_ref ) = @_; |
908
|
|
|
|
|
|
|
|
909
|
1
|
50
|
|
|
|
4
|
if ( !ref $arg_ref ) { |
|
|
50
|
|
|
|
|
|
910
|
0
|
|
|
|
|
0
|
$arg_ref = { type => $arg_ref }; |
911
|
|
|
|
|
|
|
} |
912
|
|
|
|
|
|
|
elsif ( ref $arg_ref eq 'HASH' ) { |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
# shallow clone |
915
|
1
|
|
|
|
|
5
|
$arg_ref = {%$arg_ref}; |
916
|
|
|
|
|
|
|
} |
917
|
|
|
|
|
|
|
else { |
918
|
0
|
|
|
|
|
0
|
croak 'invalid args'; |
919
|
|
|
|
|
|
|
} |
920
|
|
|
|
|
|
|
|
921
|
1
|
|
|
|
|
1
|
my $type = delete $arg_ref->{type}; |
922
|
1
|
|
|
|
|
1
|
my @return; |
923
|
|
|
|
|
|
|
|
924
|
1
|
50
|
|
|
|
4
|
my @names = map { ref $_ ? @$_ : $_ } |
925
|
1
|
|
|
|
|
4
|
grep {defined} ( delete $arg_ref->{name}, delete $arg_ref->{names} ); |
|
2
|
|
|
|
|
3
|
|
926
|
|
|
|
|
|
|
|
927
|
1
|
50
|
|
|
|
3
|
if (@names) { |
928
|
|
|
|
|
|
|
|
929
|
|
|
|
|
|
|
# add plugins to appropriate fields |
930
|
1
|
|
|
|
|
2
|
for my $x (@names) { |
931
|
1
|
|
|
|
|
2
|
for my $field ( @{ $self->get_fields( { nested_name => $x } ) } ) { |
|
1
|
|
|
|
|
7
|
|
932
|
1
|
|
|
|
|
9
|
my $new = $field->_require_plugin( $type, $arg_ref ); |
933
|
1
|
|
|
|
|
1
|
push @{ $field->_plugins }, $new; |
|
1
|
|
|
|
|
28
|
|
934
|
1
|
|
|
|
|
4
|
push @return, $new; |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
} |
937
|
|
|
|
|
|
|
} |
938
|
|
|
|
|
|
|
else { |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
# add plugin directly to form |
941
|
0
|
|
|
|
|
0
|
my $new = $self->_require_plugin( $type, $arg_ref ); |
942
|
|
|
|
|
|
|
|
943
|
0
|
|
|
|
|
0
|
push @{ $self->_plugins }, $new; |
|
0
|
|
|
|
|
0
|
|
944
|
0
|
|
|
|
|
0
|
push @return, $new; |
945
|
|
|
|
|
|
|
} |
946
|
|
|
|
|
|
|
|
947
|
1
|
|
|
|
|
7
|
return @return; |
948
|
|
|
|
|
|
|
} |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
around render => sub { |
951
|
|
|
|
|
|
|
my $orig = shift; |
952
|
|
|
|
|
|
|
my $self = shift; |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
my $plugins = $self->get_plugins; |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
for my $plugin (@$plugins) { |
957
|
|
|
|
|
|
|
$plugin->render; |
958
|
|
|
|
|
|
|
} |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
my $output = $self->$orig; |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
for my $plugin (@$plugins) { |
963
|
|
|
|
|
|
|
$plugin->post_render( \$output ); |
964
|
|
|
|
|
|
|
} |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
return $output; |
967
|
|
|
|
|
|
|
}; |
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
sub render_data { |
970
|
11
|
|
|
11
|
1
|
20
|
my ( $self, $args ) = @_; |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
my $render = $self->render_data_non_recursive( { |
973
|
11
|
50
|
|
|
|
19
|
elements => [ map { $_->render_data } @{ $self->_elements } ], |
|
28
|
|
|
|
|
165
|
|
|
11
|
|
|
|
|
266
|
|
974
|
|
|
|
|
|
|
$args ? %$args : (), |
975
|
|
|
|
|
|
|
} ); |
976
|
|
|
|
|
|
|
|
977
|
11
|
|
|
|
|
1543
|
return $render; |
978
|
|
|
|
|
|
|
} |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
sub render_data_non_recursive { |
981
|
183
|
|
|
183
|
1
|
304
|
my ( $self, $args ) = @_; |
982
|
|
|
|
|
|
|
|
983
|
183
|
100
|
|
|
|
4726
|
my %render = ( |
984
|
|
|
|
|
|
|
filename => $self->filename, |
985
|
|
|
|
|
|
|
javascript => $self->javascript, |
986
|
|
|
|
|
|
|
javascript_src => $self->javascript_src, |
987
|
|
|
|
|
|
|
attributes => xml_escape( $self->attributes ), |
988
|
|
|
|
|
|
|
stash => $self->stash, |
989
|
|
|
|
|
|
|
$args ? %$args : (), |
990
|
|
|
|
|
|
|
); |
991
|
|
|
|
|
|
|
|
992
|
183
|
|
|
|
|
491
|
$render{form} = \%render; |
993
|
183
|
|
|
|
|
724
|
weaken( $render{form} ); |
994
|
|
|
|
|
|
|
|
995
|
183
|
|
|
|
|
361
|
$render{object} = $self; |
996
|
|
|
|
|
|
|
|
997
|
183
|
100
|
100
|
|
|
4879
|
if ($self->force_error_message |
|
|
|
66
|
|
|
|
|
998
|
|
|
|
|
|
|
|| ( $self->has_errors |
999
|
|
|
|
|
|
|
&& defined $self->form_error_message ) ) |
1000
|
|
|
|
|
|
|
{ |
1001
|
3
|
|
|
|
|
9
|
$render{form_error_message} = xml_escape( $self->form_error_message ); |
1002
|
3
|
|
|
|
|
82
|
$render{form_error_message_class} = $self->form_error_message_class; |
1003
|
|
|
|
|
|
|
} |
1004
|
|
|
|
|
|
|
|
1005
|
183
|
|
|
|
|
469
|
return \%render; |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
sub string { |
1009
|
166
|
|
|
166
|
0
|
270
|
my ( $self, $args_ref ) = @_; |
1010
|
|
|
|
|
|
|
|
1011
|
166
|
|
50
|
|
|
881
|
$args_ref ||= {}; |
1012
|
|
|
|
|
|
|
|
1013
|
166
|
|
|
|
|
580
|
my $html = $self->_string_form_start( $args_ref ); |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
# form template |
1016
|
|
|
|
|
|
|
|
1017
|
166
|
|
|
|
|
339
|
$html .= "\n"; |
1018
|
|
|
|
|
|
|
|
1019
|
166
|
|
|
|
|
212
|
for my $element ( @{ $self->get_elements } ) { |
|
166
|
|
|
|
|
674
|
|
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
# call render, so that child elements can use a different renderer |
1022
|
226
|
|
|
|
|
1804
|
my $element_html = $element->render; |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
# skip Blank fields |
1025
|
226
|
100
|
|
|
|
684
|
if ( length $element_html ) { |
1026
|
225
|
|
|
|
|
1010
|
$html .= $element_html . "\n"; |
1027
|
|
|
|
|
|
|
} |
1028
|
|
|
|
|
|
|
} |
1029
|
|
|
|
|
|
|
|
1030
|
166
|
|
|
|
|
634
|
$html .= $self->_string_form_end( $args_ref ); |
1031
|
166
|
|
|
|
|
298
|
$html .= "\n"; |
1032
|
|
|
|
|
|
|
|
1033
|
166
|
|
|
|
|
599
|
return $html; |
1034
|
|
|
|
|
|
|
} |
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
sub _string_form_start { |
1037
|
172
|
|
|
172
|
|
279
|
my ( $self, $args_ref ) = @_; |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
# start_form template |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
my $render_ref |
1042
|
|
|
|
|
|
|
= exists $args_ref->{render_data} |
1043
|
|
|
|
|
|
|
? $args_ref->{render_data} |
1044
|
172
|
50
|
|
|
|
998
|
: $self->render_data_non_recursive; |
1045
|
|
|
|
|
|
|
|
1046
|
172
|
|
|
|
|
696
|
my $html = sprintf "<form%s>", process_attrs( $render_ref->{attributes} ); |
1047
|
|
|
|
|
|
|
|
1048
|
172
|
100
|
|
|
|
595
|
if ( defined $render_ref->{form_error_message} ) { |
1049
|
|
|
|
|
|
|
$html .= sprintf qq{\n<div class="%s">%s</div>}, |
1050
|
|
|
|
|
|
|
$render_ref->{form_error_message_class}, |
1051
|
|
|
|
|
|
|
$render_ref->{form_error_message}, |
1052
|
3
|
|
|
|
|
17
|
; |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
|
1055
|
172
|
100
|
|
|
|
799
|
if ( defined $render_ref->{javascript_src} ) { |
1056
|
2
|
|
|
|
|
2
|
my $uri = $render_ref->{javascript_src}; |
1057
|
|
|
|
|
|
|
|
1058
|
2
|
100
|
|
|
|
6
|
my @uris = ref $uri eq 'ARRAY' ? @$uri : ($uri); |
1059
|
|
|
|
|
|
|
|
1060
|
2
|
|
|
|
|
2
|
for my $uri (@uris) { |
1061
|
3
|
|
|
|
|
9
|
$html .= sprintf |
1062
|
|
|
|
|
|
|
qq{\n<script type="text/javascript" src="%s">\n</script>}, |
1063
|
|
|
|
|
|
|
$uri, |
1064
|
|
|
|
|
|
|
; |
1065
|
|
|
|
|
|
|
} |
1066
|
|
|
|
|
|
|
} |
1067
|
|
|
|
|
|
|
|
1068
|
172
|
100
|
|
|
|
786
|
if ( defined $render_ref->{javascript} ) { |
1069
|
|
|
|
|
|
|
$html .= sprintf |
1070
|
|
|
|
|
|
|
qq{\n<script type="text/javascript">\n%s\n</script>}, |
1071
|
|
|
|
|
|
|
$render_ref->{javascript}, |
1072
|
3
|
|
|
|
|
9
|
; |
1073
|
|
|
|
|
|
|
} |
1074
|
|
|
|
|
|
|
|
1075
|
172
|
|
|
|
|
728
|
return $html; |
1076
|
|
|
|
|
|
|
} |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
sub _string_form_end { |
1079
|
172
|
|
|
172
|
|
275
|
my ( $self ) = @_; |
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
# end_form template |
1082
|
|
|
|
|
|
|
|
1083
|
172
|
|
|
|
|
372
|
return "</form>"; |
1084
|
|
|
|
|
|
|
} |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
sub start { |
1087
|
6
|
|
|
6
|
1
|
186682
|
my $self = shift; |
1088
|
|
|
|
|
|
|
|
1089
|
6
|
50
|
|
|
|
35
|
if ( 'tt' eq $self->render_method ) { |
1090
|
0
|
|
|
|
|
0
|
return $self->tt( { |
1091
|
|
|
|
|
|
|
filename => 'start_form', |
1092
|
|
|
|
|
|
|
render_data => $self->render_data_non_recursive, |
1093
|
|
|
|
|
|
|
} ); |
1094
|
|
|
|
|
|
|
} |
1095
|
|
|
|
|
|
|
else { |
1096
|
6
|
|
|
|
|
30
|
return $self->_string_form_start( @_ ); |
1097
|
|
|
|
|
|
|
} |
1098
|
|
|
|
|
|
|
} |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
sub end { |
1101
|
6
|
|
|
6
|
1
|
271
|
my $self = shift; |
1102
|
|
|
|
|
|
|
|
1103
|
6
|
50
|
|
|
|
21
|
if ( 'tt' eq $self->render_method ) { |
1104
|
0
|
|
|
|
|
0
|
return $self->tt( { |
1105
|
|
|
|
|
|
|
filename => 'end_form', |
1106
|
|
|
|
|
|
|
render_data => $self->render_data_non_recursive, |
1107
|
|
|
|
|
|
|
} ); |
1108
|
|
|
|
|
|
|
} |
1109
|
|
|
|
|
|
|
else { |
1110
|
6
|
|
|
|
|
22
|
return $self->_string_form_end( @_ ); |
1111
|
|
|
|
|
|
|
} |
1112
|
|
|
|
|
|
|
} |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
sub hidden_fields { |
1115
|
1
|
|
|
1
|
1
|
1
|
my ($self) = @_; |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
return join $EMPTY_STR, |
1118
|
1
|
|
|
|
|
2
|
map { $_->render } @{ $self->get_fields( { type => 'Hidden' } ) }; |
|
2
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
7
|
|
1119
|
|
|
|
|
|
|
} |
1120
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
sub output_processor { |
1122
|
3
|
|
|
3
|
0
|
2105
|
my ( $self, $arg ) = @_; |
1123
|
3
|
|
|
|
|
5
|
my @return; |
1124
|
|
|
|
|
|
|
|
1125
|
3
|
50
|
|
|
|
15
|
if ( ref $arg eq 'ARRAY' ) { |
1126
|
0
|
|
|
|
|
0
|
push @return, map { $self->_single_output_processor($_) } @$arg; |
|
0
|
|
|
|
|
0
|
|
1127
|
|
|
|
|
|
|
} |
1128
|
|
|
|
|
|
|
else { |
1129
|
3
|
|
|
|
|
14
|
push @return, $self->_single_output_processor($arg); |
1130
|
|
|
|
|
|
|
} |
1131
|
|
|
|
|
|
|
|
1132
|
3
|
50
|
|
|
|
22
|
return @return == 1 ? $return[0] : @return; |
1133
|
|
|
|
|
|
|
} |
1134
|
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
sub _single_output_processor { |
1136
|
3
|
|
|
3
|
|
5
|
my ( $self, $arg ) = @_; |
1137
|
|
|
|
|
|
|
|
1138
|
3
|
100
|
|
|
|
10
|
if ( !ref $arg ) { |
|
|
50
|
|
|
|
|
|
1139
|
2
|
|
|
|
|
7
|
$arg = { type => $arg }; |
1140
|
|
|
|
|
|
|
} |
1141
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
1142
|
1
|
|
|
|
|
9
|
$arg = Clone::clone($arg); |
1143
|
|
|
|
|
|
|
} |
1144
|
|
|
|
|
|
|
else { |
1145
|
0
|
|
|
|
|
0
|
croak 'invalid args'; |
1146
|
|
|
|
|
|
|
} |
1147
|
|
|
|
|
|
|
|
1148
|
3
|
|
|
|
|
8
|
my $type = delete $arg->{type}; |
1149
|
|
|
|
|
|
|
|
1150
|
3
|
|
|
|
|
10
|
my $new = $self->_require_output_processor( $type, $arg ); |
1151
|
|
|
|
|
|
|
|
1152
|
3
|
|
|
|
|
18
|
push @{ $self->_output_processors }, $new; |
|
3
|
|
|
|
|
106
|
|
1153
|
|
|
|
|
|
|
|
1154
|
3
|
|
|
|
|
13
|
return $new; |
1155
|
|
|
|
|
|
|
} |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
sub _require_output_processor { |
1158
|
3
|
|
|
3
|
|
7
|
my ( $self, $type, $opt ) = @_; |
1159
|
|
|
|
|
|
|
|
1160
|
3
|
50
|
|
|
|
14
|
croak 'required arguments: $self, $type, \%options' if @_ != 3; |
1161
|
|
|
|
|
|
|
|
1162
|
3
|
50
|
|
|
|
18
|
croak "options argument must be hash-ref" |
1163
|
|
|
|
|
|
|
if reftype($opt) ne 'HASH'; |
1164
|
|
|
|
|
|
|
|
1165
|
3
|
|
|
|
|
7
|
my $class = $type; |
1166
|
3
|
50
|
|
|
|
13
|
if ( not $class =~ s/^\+// ) { |
1167
|
3
|
|
|
|
|
9
|
$class = "HTML::FormFu::OutputProcessor::$class"; |
1168
|
|
|
|
|
|
|
} |
1169
|
|
|
|
|
|
|
|
1170
|
3
|
|
|
|
|
8
|
$type =~ s/^\+//; |
1171
|
|
|
|
|
|
|
|
1172
|
3
|
|
|
|
|
15
|
require_class($class); |
1173
|
|
|
|
|
|
|
|
1174
|
3
|
|
|
|
|
142
|
my $object = $class->new( { |
1175
|
|
|
|
|
|
|
type => $type, |
1176
|
|
|
|
|
|
|
parent => $self, |
1177
|
|
|
|
|
|
|
} ); |
1178
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
# handle default_args |
1180
|
3
|
|
|
|
|
17
|
my $parent = $self->parent; |
1181
|
|
|
|
|
|
|
|
1182
|
3
|
0
|
33
|
|
|
13
|
if ( $parent && exists $parent->default_args->{output_processor}{$type} ) { |
1183
|
|
|
|
|
|
|
%$opt |
1184
|
0
|
|
|
|
|
0
|
= ( %{ $parent->default_args->{output_processer}{$type} }, %$opt ); |
|
0
|
|
|
|
|
0
|
|
1185
|
|
|
|
|
|
|
} |
1186
|
|
|
|
|
|
|
|
1187
|
3
|
|
|
|
|
13
|
$object->populate($opt); |
1188
|
|
|
|
|
|
|
|
1189
|
3
|
|
|
|
|
9
|
return $object; |
1190
|
|
|
|
|
|
|
} |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
sub get_output_processors { |
1193
|
1116
|
|
|
1116
|
0
|
1174
|
my $self = shift; |
1194
|
1116
|
|
|
|
|
2656
|
my %args = _parse_args(@_); |
1195
|
|
|
|
|
|
|
|
1196
|
1116
|
|
|
|
|
1239
|
my @x = @{ $self->_output_processors }; |
|
1116
|
|
|
|
|
28761
|
|
1197
|
|
|
|
|
|
|
|
1198
|
1116
|
50
|
|
|
|
2247
|
if ( exists $args{type} ) { |
1199
|
0
|
|
|
|
|
0
|
@x = grep { $_->type eq $args{type} } @x; |
|
0
|
|
|
|
|
0
|
|
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
1116
|
|
|
|
|
3015
|
return \@x; |
1203
|
|
|
|
|
|
|
} |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
sub get_output_processor { |
1206
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
1207
|
|
|
|
|
|
|
|
1208
|
0
|
|
|
|
|
|
my $x = $self->get_output_processors(@_); |
1209
|
|
|
|
|
|
|
|
1210
|
0
|
0
|
|
|
|
|
return @$x ? $x->[0] : (); |
1211
|
|
|
|
|
|
|
} |
1212
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
1; |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
__END__ |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
=head1 NAME |
1220
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
HTML::FormFu - HTML Form Creation, Rendering and Validation Framework |
1222
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=head1 VERSION |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
version 2.05 |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=head1 SYNOPSIS |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
Note: These examples make use of L<HTML::FormFu::Model::DBIC>. As of |
1230
|
|
|
|
|
|
|
C<HTML::FormFu> v02.005, the L<HTML::FormFu::Model::DBIC> module is |
1231
|
|
|
|
|
|
|
not bundled with C<HTML::FormFu> and is available in a stand-alone |
1232
|
|
|
|
|
|
|
distribution. |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
use HTML::FormFu; |
1235
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
my $form = HTML::FormFu->new; |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
$form->load_config_file('form.yml'); |
1239
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
$form->process( $cgi_query ); |
1241
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
if ( $form->submitted_and_valid ) { |
1243
|
|
|
|
|
|
|
# do something with $form->params |
1244
|
|
|
|
|
|
|
} |
1245
|
|
|
|
|
|
|
else { |
1246
|
|
|
|
|
|
|
# display the form |
1247
|
|
|
|
|
|
|
$template->param( form => $form ); |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
If you're using L<Catalyst>, a more suitable example might be: |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
package MyApp::Controller::User; |
1253
|
|
|
|
|
|
|
use Moose; |
1254
|
|
|
|
|
|
|
extends 'Catalyst::Controller::HTML::FormFu'; |
1255
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
sub user : FormFuChained CaptureArgs(1) { |
1257
|
|
|
|
|
|
|
my ( $self, $c, $id ) = @_; |
1258
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
my $rs = $c->model('Schema')->resultset('User'); |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
$c->stash->{user} = $rs->find( $id ); |
1262
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
return; |
1264
|
|
|
|
|
|
|
} |
1265
|
|
|
|
|
|
|
|
1266
|
|
|
|
|
|
|
sub edit : FormFuChained('user') Args(0) FormConfig { |
1267
|
|
|
|
|
|
|
my ( $self, $c ) = @_; |
1268
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
my $form = $c->stash->{form}; |
1270
|
|
|
|
|
|
|
my $user = $c->stash->{user}; |
1271
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
if ( $form->submitted_and_valid ) { |
1273
|
|
|
|
|
|
|
|
1274
|
|
|
|
|
|
|
$form->model->update( $user ); |
1275
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
$c->res->redirect( $c->uri_for( "/user/$id" ) ); |
1277
|
|
|
|
|
|
|
return; |
1278
|
|
|
|
|
|
|
} |
1279
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
$form->model->default_values( $user ) |
1281
|
|
|
|
|
|
|
if ! $form->submitted; |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
} |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
Note: Because L</process> is automatically called for you by the Catalyst |
1286
|
|
|
|
|
|
|
controller; if you make any modifications to the form within your action |
1287
|
|
|
|
|
|
|
method, such as adding or changing elements, adding constraints, etc; |
1288
|
|
|
|
|
|
|
you must call L</process> again yourself before using L</submitted_and_valid>, |
1289
|
|
|
|
|
|
|
any of the methods listed under L</"SUBMITTED FORM VALUES AND ERRORS"> or |
1290
|
|
|
|
|
|
|
L</"MODIFYING A SUBMITTED FORM">, or rendering the form. |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
Here's an example of a config file to create a basic login form (all examples |
1293
|
|
|
|
|
|
|
here are L<YAML>, but you can use any format supported by L<Config::Any>), |
1294
|
|
|
|
|
|
|
you can also create forms directly in your perl code, rather than using an |
1295
|
|
|
|
|
|
|
external config file. |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
--- |
1298
|
|
|
|
|
|
|
action: /login |
1299
|
|
|
|
|
|
|
indicator: submit |
1300
|
|
|
|
|
|
|
auto_fieldset: 1 |
1301
|
|
|
|
|
|
|
|
1302
|
|
|
|
|
|
|
elements: |
1303
|
|
|
|
|
|
|
- type: Text |
1304
|
|
|
|
|
|
|
name: user |
1305
|
|
|
|
|
|
|
constraints: |
1306
|
|
|
|
|
|
|
- Required |
1307
|
|
|
|
|
|
|
|
1308
|
|
|
|
|
|
|
- type: Password |
1309
|
|
|
|
|
|
|
name: pass |
1310
|
|
|
|
|
|
|
constraints: |
1311
|
|
|
|
|
|
|
- Required |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
- type: Submit |
1314
|
|
|
|
|
|
|
name: submit |
1315
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
constraints: |
1317
|
|
|
|
|
|
|
- SingleValue |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
=head1 DESCRIPTION |
1320
|
|
|
|
|
|
|
|
1321
|
|
|
|
|
|
|
L<HTML::FormFu> is a HTML form framework which aims to be as easy as |
1322
|
|
|
|
|
|
|
possible to use for basic web forms, but with the power and flexibility to |
1323
|
|
|
|
|
|
|
do anything else you might want to do (as long as it involves forms). |
1324
|
|
|
|
|
|
|
|
1325
|
|
|
|
|
|
|
You can configure almost any part of formfu's behaviour and output. By |
1326
|
|
|
|
|
|
|
default formfu renders "XHTML 1.0 Strict" compliant markup, with as little |
1327
|
|
|
|
|
|
|
extra markup as possible, but with sufficient CSS class names to allow for a |
1328
|
|
|
|
|
|
|
wide-range of output styles to be generated by changing only the CSS. |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
All methods listed below (except L</new>) can either be called as a normal |
1331
|
|
|
|
|
|
|
method on your C<$form> object, or as an option in your config file. Examples |
1332
|
|
|
|
|
|
|
will mainly be shown in L<YAML> config syntax. |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
This documentation follows the convention that method arguments surrounded |
1335
|
|
|
|
|
|
|
by square brackets C<[]> are I<optional>, and all other arguments are |
1336
|
|
|
|
|
|
|
required. |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
=head1 BUILDING A FORM |
1339
|
|
|
|
|
|
|
|
1340
|
|
|
|
|
|
|
=head2 new |
1341
|
|
|
|
|
|
|
|
1342
|
|
|
|
|
|
|
Arguments: [\%options] |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
Return Value: $form |
1345
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
Create a new L<HTML::FormFu|HTML::FormFu> object. |
1347
|
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
Any method which can be called on the L<HTML::FormFu|HTML::FormFu> object may |
1349
|
|
|
|
|
|
|
instead be passed as an argument to L</new>. |
1350
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
my $form = HTML::FormFu->new({ |
1352
|
|
|
|
|
|
|
action => '/search', |
1353
|
|
|
|
|
|
|
method => 'GET', |
1354
|
|
|
|
|
|
|
auto_fieldset => 1, |
1355
|
|
|
|
|
|
|
}); |
1356
|
|
|
|
|
|
|
|
1357
|
|
|
|
|
|
|
=head2 load_config_file |
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
Arguments: $filename |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
Arguments: \@filenames |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
Return Value: $form |
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
Accepts a filename or list of file names, whose filetypes should be of any |
1366
|
|
|
|
|
|
|
format recognized by L<Config::Any>. |
1367
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
The content of each config file is passed to L</populate>, and so are added |
1369
|
|
|
|
|
|
|
to the form. |
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
L</load_config_file> may be called in a config file itself, so as to allow |
1372
|
|
|
|
|
|
|
common settings to be kept in a single config file which may be loaded |
1373
|
|
|
|
|
|
|
by any form. |
1374
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
--- |
1376
|
|
|
|
|
|
|
load_config_file: |
1377
|
|
|
|
|
|
|
- file1 |
1378
|
|
|
|
|
|
|
- file2 |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
YAML multiple documents within a single file. The document start marker is |
1381
|
|
|
|
|
|
|
a line containing 3 dashes. Multiple documents will be applied in order, |
1382
|
|
|
|
|
|
|
just as if multiple filenames had been given. |
1383
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
In the following example, multiple documents are taken advantage of to |
1385
|
|
|
|
|
|
|
load another config file after the elements are added. (If this were |
1386
|
|
|
|
|
|
|
a single document, the C<load_config_file> would be called before |
1387
|
|
|
|
|
|
|
C<elements>, regardless of its position in the file). |
1388
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
--- |
1390
|
|
|
|
|
|
|
elements: |
1391
|
|
|
|
|
|
|
- name: one |
1392
|
|
|
|
|
|
|
- name: two |
1393
|
|
|
|
|
|
|
|
1394
|
|
|
|
|
|
|
--- |
1395
|
|
|
|
|
|
|
load_config_file: ext.yml |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
Relative paths are resolved from the L</config_file_path> directory if |
1398
|
|
|
|
|
|
|
it is set, otherwise from the current working directory. |
1399
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
See L</BEST PRACTICES> for advice on organising config files. |
1401
|
|
|
|
|
|
|
|
1402
|
|
|
|
|
|
|
=head2 config_callback |
1403
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
Arguments: \%options |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
If defined, the arguments are used to create a L<Data::Visitor::Callback> |
1407
|
|
|
|
|
|
|
object during L</load_config_file> which may be used to pre-process the |
1408
|
|
|
|
|
|
|
config before it is sent to L</populate>. |
1409
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
For example, the code below adds a callback to a form that will dynamically |
1411
|
|
|
|
|
|
|
alter any config value ending in ".yml" to end in ".yaml" when you call |
1412
|
|
|
|
|
|
|
L</load_config_file>: |
1413
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
$form->config_callback({ |
1415
|
|
|
|
|
|
|
plain_value => sub { |
1416
|
|
|
|
|
|
|
my( $visitor, $data ) = @_; |
1417
|
|
|
|
|
|
|
s/\.yml/.yaml/; |
1418
|
|
|
|
|
|
|
} |
1419
|
|
|
|
|
|
|
}); |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
|
1422
|
|
|
|
|
|
|
Default Value: not defined |
1423
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
1425
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
1426
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
1427
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
1428
|
|
|
|
|
|
|
defined value. |
1429
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
=head2 populate |
1431
|
|
|
|
|
|
|
|
1432
|
|
|
|
|
|
|
Arguments: \%options |
1433
|
|
|
|
|
|
|
|
1434
|
|
|
|
|
|
|
Return Value: $form |
1435
|
|
|
|
|
|
|
|
1436
|
|
|
|
|
|
|
Each option key/value passed may be any L<HTML::FormFu|HTML::FormFu> |
1437
|
|
|
|
|
|
|
method-name and arguments. |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
Provides a simple way to set multiple values, or add multiple elements to |
1440
|
|
|
|
|
|
|
a form with a single method-call. |
1441
|
|
|
|
|
|
|
|
1442
|
|
|
|
|
|
|
Attempts to call the method-names in a semi-intelligent order (see |
1443
|
|
|
|
|
|
|
the source of populate() in C<HTML::FormFu::ObjectUtil> for details). |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
=head2 default_values |
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
Arguments: \%defaults |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
Return Value: $form |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
Set multiple field's default values from a single hash-ref. |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
The hash-ref's keys correspond to a form field's name, and the value is |
1454
|
|
|
|
|
|
|
passed to the field's L<default method|HTML::FormFu::_Field/default>. |
1455
|
|
|
|
|
|
|
|
1456
|
|
|
|
|
|
|
This should be called after all fields have been added to the form, and |
1457
|
|
|
|
|
|
|
before L</process> is called (otherwise, call L</process> again before |
1458
|
|
|
|
|
|
|
rendering the form). |
1459
|
|
|
|
|
|
|
|
1460
|
|
|
|
|
|
|
=head2 config_file_path |
1461
|
|
|
|
|
|
|
|
1462
|
|
|
|
|
|
|
Arguments: $directory_name |
1463
|
|
|
|
|
|
|
|
1464
|
|
|
|
|
|
|
L</config_file_path> defines where configuration files will be |
1465
|
|
|
|
|
|
|
searched for, if an absolute path is not given to |
1466
|
|
|
|
|
|
|
L</load_config_file>. |
1467
|
|
|
|
|
|
|
|
1468
|
|
|
|
|
|
|
Default Value: not defined |
1469
|
|
|
|
|
|
|
|
1470
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
1471
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
1472
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
1473
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
1474
|
|
|
|
|
|
|
defined value. |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
Is an L<inheriting accessor|/INHERITING ACCESSORS>. |
1477
|
|
|
|
|
|
|
|
1478
|
|
|
|
|
|
|
=head2 indicator |
1479
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
Arguments: $field_name |
1481
|
|
|
|
|
|
|
|
1482
|
|
|
|
|
|
|
Arguments: \&coderef |
1483
|
|
|
|
|
|
|
|
1484
|
|
|
|
|
|
|
If L</indicator> is set to a fieldname, L</submitted> will return true if |
1485
|
|
|
|
|
|
|
a value for that fieldname was submitted. |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
If L</indicator> is set to a code-ref, it will be called as a subroutine |
1488
|
|
|
|
|
|
|
with the two arguments C<$form> and C<$query>, and its return value will be |
1489
|
|
|
|
|
|
|
used as the return value for L</submitted>. |
1490
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
If L</indicator> is not set, L</submitted> will return true if a value for |
1492
|
|
|
|
|
|
|
any known fieldname was submitted. |
1493
|
|
|
|
|
|
|
|
1494
|
|
|
|
|
|
|
=head2 auto_fieldset |
1495
|
|
|
|
|
|
|
|
1496
|
|
|
|
|
|
|
Arguments: 1 |
1497
|
|
|
|
|
|
|
|
1498
|
|
|
|
|
|
|
Arguments: \%options |
1499
|
|
|
|
|
|
|
|
1500
|
|
|
|
|
|
|
Return Value: $fieldset |
1501
|
|
|
|
|
|
|
|
1502
|
|
|
|
|
|
|
This setting is suitable for most basic forms, and means you can generally |
1503
|
|
|
|
|
|
|
ignore adding fieldsets yourself. |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
Calling C<< $form->auto_fieldset(1) >> immediately adds a fieldset element to |
1506
|
|
|
|
|
|
|
the form. Thereafter, C<< $form->elements() >> will add all elements (except |
1507
|
|
|
|
|
|
|
fieldsets) to that fieldset, rather than directly to the form. |
1508
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
To be specific, the elements are added to the I<last> fieldset on the form, |
1510
|
|
|
|
|
|
|
so if you add another fieldset, any further elements will be added to that |
1511
|
|
|
|
|
|
|
fieldset. |
1512
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
Also, you may pass a hashref to auto_fieldset(), and this will be used |
1514
|
|
|
|
|
|
|
to set defaults for the first fieldset created. |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
A few examples and their output, to demonstrate: |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
2 elements with no fieldset. |
1519
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
--- |
1521
|
|
|
|
|
|
|
elements: |
1522
|
|
|
|
|
|
|
- type: Text |
1523
|
|
|
|
|
|
|
name: foo |
1524
|
|
|
|
|
|
|
- type: Text |
1525
|
|
|
|
|
|
|
name: bar |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
<form action="" method="post"> |
1528
|
|
|
|
|
|
|
<div class="text"> |
1529
|
|
|
|
|
|
|
<input name="foo" type="text" /> |
1530
|
|
|
|
|
|
|
</div> |
1531
|
|
|
|
|
|
|
<div class="text"> |
1532
|
|
|
|
|
|
|
<input name="bar" type="text" /> |
1533
|
|
|
|
|
|
|
</div> |
1534
|
|
|
|
|
|
|
</form> |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
2 elements with an L</auto_fieldset>. |
1537
|
|
|
|
|
|
|
|
1538
|
|
|
|
|
|
|
--- |
1539
|
|
|
|
|
|
|
auto_fieldset: 1 |
1540
|
|
|
|
|
|
|
elements: |
1541
|
|
|
|
|
|
|
- type: Text |
1542
|
|
|
|
|
|
|
name: foo |
1543
|
|
|
|
|
|
|
- type: Text |
1544
|
|
|
|
|
|
|
name: bar |
1545
|
|
|
|
|
|
|
|
1546
|
|
|
|
|
|
|
<form action="" method="post"> |
1547
|
|
|
|
|
|
|
<fieldset> |
1548
|
|
|
|
|
|
|
<div class="text"> |
1549
|
|
|
|
|
|
|
<input name="foo" type="text" /> |
1550
|
|
|
|
|
|
|
</div> |
1551
|
|
|
|
|
|
|
<div class="text"> |
1552
|
|
|
|
|
|
|
<input name="bar" type="text" /> |
1553
|
|
|
|
|
|
|
</div> |
1554
|
|
|
|
|
|
|
</fieldset> |
1555
|
|
|
|
|
|
|
</form> |
1556
|
|
|
|
|
|
|
|
1557
|
|
|
|
|
|
|
The 3rd element is within a new fieldset |
1558
|
|
|
|
|
|
|
|
1559
|
|
|
|
|
|
|
--- |
1560
|
|
|
|
|
|
|
auto_fieldset: { id: fs } |
1561
|
|
|
|
|
|
|
elements: |
1562
|
|
|
|
|
|
|
- type: Text |
1563
|
|
|
|
|
|
|
name: foo |
1564
|
|
|
|
|
|
|
- type: Text |
1565
|
|
|
|
|
|
|
name: bar |
1566
|
|
|
|
|
|
|
- type: Fieldset |
1567
|
|
|
|
|
|
|
- type: Text |
1568
|
|
|
|
|
|
|
name: baz |
1569
|
|
|
|
|
|
|
|
1570
|
|
|
|
|
|
|
<form action="" method="post"> |
1571
|
|
|
|
|
|
|
<fieldset id="fs"> |
1572
|
|
|
|
|
|
|
<div class="text"> |
1573
|
|
|
|
|
|
|
<input name="foo" type="text" /> |
1574
|
|
|
|
|
|
|
</div> |
1575
|
|
|
|
|
|
|
<div class="text"> |
1576
|
|
|
|
|
|
|
<input name="bar" type="text" /> |
1577
|
|
|
|
|
|
|
</div> |
1578
|
|
|
|
|
|
|
</fieldset> |
1579
|
|
|
|
|
|
|
<fieldset> |
1580
|
|
|
|
|
|
|
<div class="text"> |
1581
|
|
|
|
|
|
|
<input name="baz" type="text" /> |
1582
|
|
|
|
|
|
|
</div> |
1583
|
|
|
|
|
|
|
</fieldset> |
1584
|
|
|
|
|
|
|
</form> |
1585
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
Because of this behaviour, if you want nested fieldsets you will have to add |
1587
|
|
|
|
|
|
|
each nested fieldset directly to its intended parent. |
1588
|
|
|
|
|
|
|
|
1589
|
|
|
|
|
|
|
my $parent = $form->get_element({ type => 'Fieldset' }); |
1590
|
|
|
|
|
|
|
|
1591
|
|
|
|
|
|
|
$parent->element('fieldset'); |
1592
|
|
|
|
|
|
|
|
1593
|
|
|
|
|
|
|
=head2 form_error_message |
1594
|
|
|
|
|
|
|
|
1595
|
|
|
|
|
|
|
Arguments: $string |
1596
|
|
|
|
|
|
|
|
1597
|
|
|
|
|
|
|
Normally, input errors cause an error message to be displayed alongside the |
1598
|
|
|
|
|
|
|
appropriate form field. If you'd also like a general error message to be |
1599
|
|
|
|
|
|
|
displayed at the top of the form, you can set the message with |
1600
|
|
|
|
|
|
|
L</form_error_message>. |
1601
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
To set the CSS class for the message, see L</form_error_message_class>. |
1603
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
To change the markup used to display the message, edit the |
1605
|
|
|
|
|
|
|
C<form_error_message> template file. See L</render_method>. |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
Is an L<output accessor|HTML::FormFu/OUTPUT ACCESSORS>. |
1608
|
|
|
|
|
|
|
|
1609
|
|
|
|
|
|
|
=head2 force_error_message |
1610
|
|
|
|
|
|
|
|
1611
|
|
|
|
|
|
|
If true, forces the L</form_error_message> to be displayed even if there are |
1612
|
|
|
|
|
|
|
no field errors. |
1613
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
=head2 default_args |
1615
|
|
|
|
|
|
|
|
1616
|
|
|
|
|
|
|
Arguments: \%defaults |
1617
|
|
|
|
|
|
|
|
1618
|
|
|
|
|
|
|
Set defaults which will be added to every element, constraint, etc. of the |
1619
|
|
|
|
|
|
|
given type which is subsequently added to the form. |
1620
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
For example, to make every C<Text> element automatically have a size of |
1622
|
|
|
|
|
|
|
C<10>, and make every C<Strftime> deflator automatically get its strftime |
1623
|
|
|
|
|
|
|
set to C<%d/%m/%Y>: |
1624
|
|
|
|
|
|
|
|
1625
|
|
|
|
|
|
|
default_args: |
1626
|
|
|
|
|
|
|
elements: |
1627
|
|
|
|
|
|
|
Text: |
1628
|
|
|
|
|
|
|
size: 10 |
1629
|
|
|
|
|
|
|
deflators: |
1630
|
|
|
|
|
|
|
Strftime: |
1631
|
|
|
|
|
|
|
strftime: '%d/%m/%Y' |
1632
|
|
|
|
|
|
|
|
1633
|
|
|
|
|
|
|
An example to make all DateTime elements automatically get an appropriate |
1634
|
|
|
|
|
|
|
Strftime deflator and a DateTime inflator: |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
default_args: |
1637
|
|
|
|
|
|
|
elements: |
1638
|
|
|
|
|
|
|
DateTime: |
1639
|
|
|
|
|
|
|
deflators: |
1640
|
|
|
|
|
|
|
type: Strftime |
1641
|
|
|
|
|
|
|
strftime: '%d-%m-%Y' |
1642
|
|
|
|
|
|
|
inflators: |
1643
|
|
|
|
|
|
|
type: DateTime |
1644
|
|
|
|
|
|
|
parser: |
1645
|
|
|
|
|
|
|
strptime: '%d-%m-%Y' |
1646
|
|
|
|
|
|
|
|
1647
|
|
|
|
|
|
|
=head3 Pseudo types |
1648
|
|
|
|
|
|
|
|
1649
|
|
|
|
|
|
|
As a special case, you can also use the C<elements> keys C<Block>, C<Field> |
1650
|
|
|
|
|
|
|
and C<Input> to match any element which inherits from |
1651
|
|
|
|
|
|
|
L<HTML::FormFu::Element::Block> or which C<does> |
1652
|
|
|
|
|
|
|
L<HTML::FormFu::Role::Element::Field> or |
1653
|
|
|
|
|
|
|
L<HTML::FormFu::Role::Element::Input>. |
1654
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
=head3 Alternatives |
1656
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
Each C<elements> key can contain an C<any> list using the C<|> divider: e.g. |
1658
|
|
|
|
|
|
|
|
1659
|
|
|
|
|
|
|
# apply the given class to any Element of type Password or Button |
1660
|
|
|
|
|
|
|
default_args: |
1661
|
|
|
|
|
|
|
elements: |
1662
|
|
|
|
|
|
|
'Password|Button': |
1663
|
|
|
|
|
|
|
attrs: |
1664
|
|
|
|
|
|
|
class: novalidate |
1665
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
=head3 Match ancestor |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
Each C<elements> key list can contain a type starting with C<+> to only |
1669
|
|
|
|
|
|
|
match elements with an ancestor of the given type: e.g. |
1670
|
|
|
|
|
|
|
|
1671
|
|
|
|
|
|
|
# only apple the given class to an Input field within a Multi block |
1672
|
|
|
|
|
|
|
default_args: |
1673
|
|
|
|
|
|
|
elements: |
1674
|
|
|
|
|
|
|
'Input|+Multi': |
1675
|
|
|
|
|
|
|
attrs: |
1676
|
|
|
|
|
|
|
class: novalidate |
1677
|
|
|
|
|
|
|
|
1678
|
|
|
|
|
|
|
=head3 Don't match ancestor |
1679
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
Each C<elements> key list can contain a type starting with C<-> to only |
1681
|
|
|
|
|
|
|
match elements who do not have an ancestor of the given type: e.g. |
1682
|
|
|
|
|
|
|
|
1683
|
|
|
|
|
|
|
# apply the given class only to Input fields that are not in a Multi block |
1684
|
|
|
|
|
|
|
default_args: |
1685
|
|
|
|
|
|
|
elements: |
1686
|
|
|
|
|
|
|
'Input|-Multi': |
1687
|
|
|
|
|
|
|
attrs: |
1688
|
|
|
|
|
|
|
clasS: validate |
1689
|
|
|
|
|
|
|
|
1690
|
|
|
|
|
|
|
=head3 Order |
1691
|
|
|
|
|
|
|
|
1692
|
|
|
|
|
|
|
The arguments are applied in least- to most-specific order: |
1693
|
|
|
|
|
|
|
C<Block>, C<Field>, C<Input>, C<$type>. Within each of these, arguments are |
1694
|
|
|
|
|
|
|
applied in order of shortest-first to longest-last. |
1695
|
|
|
|
|
|
|
|
1696
|
|
|
|
|
|
|
The C<type> key must match the value returned by C<type>, e.g. |
1697
|
|
|
|
|
|
|
L<HTML::FormFu::Element/type>. If, for example, you have a custom element |
1698
|
|
|
|
|
|
|
outside of the C<HTML::FormFu::Element::*> namespace, which you load via |
1699
|
|
|
|
|
|
|
C<< $form->element({ type => '+My::Custom::Element' }) >>, the key given to |
1700
|
|
|
|
|
|
|
L</default_args> should B<not> include the leading C<+>, as that is |
1701
|
|
|
|
|
|
|
stripped-out of the returned C<type()> value. Example: |
1702
|
|
|
|
|
|
|
|
1703
|
|
|
|
|
|
|
# don't include the leading '+' here |
1704
|
|
|
|
|
|
|
default_args: |
1705
|
|
|
|
|
|
|
elements: |
1706
|
|
|
|
|
|
|
'My::Custom::Element': |
1707
|
|
|
|
|
|
|
attrs: |
1708
|
|
|
|
|
|
|
class: whatever |
1709
|
|
|
|
|
|
|
|
1710
|
|
|
|
|
|
|
# do include the leading '+' here |
1711
|
|
|
|
|
|
|
elements: |
1712
|
|
|
|
|
|
|
- type: +My::Custom::Element |
1713
|
|
|
|
|
|
|
|
1714
|
|
|
|
|
|
|
=head3 Clashes |
1715
|
|
|
|
|
|
|
|
1716
|
|
|
|
|
|
|
L</default_args> generates a single hashref to pass to L</populate>, merging |
1717
|
|
|
|
|
|
|
arguments for each type in turn - meaning L</populate> is only called once |
1718
|
|
|
|
|
|
|
in total - not once for each type. |
1719
|
|
|
|
|
|
|
Because scalar values are B<not> merged - this means later values will |
1720
|
|
|
|
|
|
|
override earlier values: e.g. |
1721
|
|
|
|
|
|
|
|
1722
|
|
|
|
|
|
|
# Normally, calling $field->add_attrs({ class => 'input' }) |
1723
|
|
|
|
|
|
|
# then calling $field->add_attrs({ class => 'not-in-multi' }) |
1724
|
|
|
|
|
|
|
# would result in both values being retained: |
1725
|
|
|
|
|
|
|
# class="input not-in-multi" |
1726
|
|
|
|
|
|
|
# |
1727
|
|
|
|
|
|
|
# However, default_args() creates a single data-structure to pass once |
1728
|
|
|
|
|
|
|
# to populate(), so any scalar values will overwrite earlier ones |
1729
|
|
|
|
|
|
|
# before they reach populate(). |
1730
|
|
|
|
|
|
|
# |
1731
|
|
|
|
|
|
|
# The below example would result in the longest-matching key |
1732
|
|
|
|
|
|
|
# overwriting any others: |
1733
|
|
|
|
|
|
|
# class="not-in-multi" |
1734
|
|
|
|
|
|
|
# |
1735
|
|
|
|
|
|
|
default_args: |
1736
|
|
|
|
|
|
|
elements: |
1737
|
|
|
|
|
|
|
Input: |
1738
|
|
|
|
|
|
|
add_attrs: |
1739
|
|
|
|
|
|
|
class: input |
1740
|
|
|
|
|
|
|
'Input:-Multi': |
1741
|
|
|
|
|
|
|
add_attrs: |
1742
|
|
|
|
|
|
|
class: not-in-multi |
1743
|
|
|
|
|
|
|
|
1744
|
|
|
|
|
|
|
=head3 Strictness |
1745
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
Note: Unlike the proper methods which have aliases, for example L</elements> |
1747
|
|
|
|
|
|
|
which is an alias for L</element> - the keys given to C<default_args> must |
1748
|
|
|
|
|
|
|
be of the plural form, e.g.: |
1749
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
default_args: |
1751
|
|
|
|
|
|
|
elements: {} |
1752
|
|
|
|
|
|
|
deflators: {} |
1753
|
|
|
|
|
|
|
filters: {} |
1754
|
|
|
|
|
|
|
constraints: {} |
1755
|
|
|
|
|
|
|
inflators: {} |
1756
|
|
|
|
|
|
|
validators: {} |
1757
|
|
|
|
|
|
|
transformers: {} |
1758
|
|
|
|
|
|
|
output_processors: {} |
1759
|
|
|
|
|
|
|
|
1760
|
|
|
|
|
|
|
=head2 javascript |
1761
|
|
|
|
|
|
|
|
1762
|
|
|
|
|
|
|
If set, the contents will be rendered within a C<script> tag, inside the top |
1763
|
|
|
|
|
|
|
of the form. |
1764
|
|
|
|
|
|
|
|
1765
|
|
|
|
|
|
|
=head2 javascript_src |
1766
|
|
|
|
|
|
|
|
1767
|
|
|
|
|
|
|
Arguments: $url |
1768
|
|
|
|
|
|
|
|
1769
|
|
|
|
|
|
|
Arguments: \@urls |
1770
|
|
|
|
|
|
|
|
1771
|
|
|
|
|
|
|
Adds a C<script> tag for each URL, immediately before any L</javascript> |
1772
|
|
|
|
|
|
|
section. |
1773
|
|
|
|
|
|
|
|
1774
|
|
|
|
|
|
|
=head2 stash |
1775
|
|
|
|
|
|
|
|
1776
|
|
|
|
|
|
|
Arguments: [\%private_stash] |
1777
|
|
|
|
|
|
|
|
1778
|
|
|
|
|
|
|
Return Value: \%stash |
1779
|
|
|
|
|
|
|
|
1780
|
|
|
|
|
|
|
Provides a hash-ref in which you can store any data you might want to |
1781
|
|
|
|
|
|
|
associate with the form. |
1782
|
|
|
|
|
|
|
|
1783
|
|
|
|
|
|
|
--- |
1784
|
|
|
|
|
|
|
stash: |
1785
|
|
|
|
|
|
|
foo: value |
1786
|
|
|
|
|
|
|
bar: value |
1787
|
|
|
|
|
|
|
|
1788
|
|
|
|
|
|
|
=head2 elements |
1789
|
|
|
|
|
|
|
|
1790
|
|
|
|
|
|
|
=head2 element |
1791
|
|
|
|
|
|
|
|
1792
|
|
|
|
|
|
|
Arguments: $type |
1793
|
|
|
|
|
|
|
|
1794
|
|
|
|
|
|
|
Arguments: \%options |
1795
|
|
|
|
|
|
|
|
1796
|
|
|
|
|
|
|
Return Value: $element |
1797
|
|
|
|
|
|
|
|
1798
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
1799
|
|
|
|
|
|
|
|
1800
|
|
|
|
|
|
|
Return Value: @elements |
1801
|
|
|
|
|
|
|
|
1802
|
|
|
|
|
|
|
Adds a new element to the form. See |
1803
|
|
|
|
|
|
|
L<HTML::FormFu::Element/"CORE FORM FIELDS"> and |
1804
|
|
|
|
|
|
|
L<HTML::FormFu::Element/"OTHER CORE ELEMENTS"> |
1805
|
|
|
|
|
|
|
for a list of core elements. |
1806
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
If you want to load an element from a namespace other than |
1808
|
|
|
|
|
|
|
C<HTML::FormFu::Element::>, you can use a fully qualified package-name by |
1809
|
|
|
|
|
|
|
prefixing it with C<+>. |
1810
|
|
|
|
|
|
|
|
1811
|
|
|
|
|
|
|
--- |
1812
|
|
|
|
|
|
|
elements: |
1813
|
|
|
|
|
|
|
- type: +MyApp::CustomElement |
1814
|
|
|
|
|
|
|
name: foo |
1815
|
|
|
|
|
|
|
|
1816
|
|
|
|
|
|
|
If a C<type> is not provided in the C<\%options>, the default C<Text> will |
1817
|
|
|
|
|
|
|
be used. |
1818
|
|
|
|
|
|
|
|
1819
|
|
|
|
|
|
|
L</element> is an alias for L</elements>. |
1820
|
|
|
|
|
|
|
|
1821
|
|
|
|
|
|
|
=head2 deflators |
1822
|
|
|
|
|
|
|
|
1823
|
|
|
|
|
|
|
=head2 deflator |
1824
|
|
|
|
|
|
|
|
1825
|
|
|
|
|
|
|
Arguments: $type |
1826
|
|
|
|
|
|
|
|
1827
|
|
|
|
|
|
|
Arguments: \%options |
1828
|
|
|
|
|
|
|
|
1829
|
|
|
|
|
|
|
Return Value: $deflator |
1830
|
|
|
|
|
|
|
|
1831
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
1832
|
|
|
|
|
|
|
|
1833
|
|
|
|
|
|
|
Return Value: @deflators |
1834
|
|
|
|
|
|
|
|
1835
|
|
|
|
|
|
|
A L<deflator|HTML::FormFu::Deflator> may be associated with any form field, |
1836
|
|
|
|
|
|
|
and allows you to provide |
1837
|
|
|
|
|
|
|
L<< $field->default|HTML::FormFu::Role::Element::Field/default >> with a value |
1838
|
|
|
|
|
|
|
which may be an object. |
1839
|
|
|
|
|
|
|
|
1840
|
|
|
|
|
|
|
If an object doesn't stringify to a suitable value for display, the |
1841
|
|
|
|
|
|
|
L<deflator|HTML::FormFu::Deflator> can ensure that the form field |
1842
|
|
|
|
|
|
|
receives a suitable string value instead. |
1843
|
|
|
|
|
|
|
|
1844
|
|
|
|
|
|
|
See L<HTML::FormFu::Deflator/"CORE DEFLATORS"> for a list of core deflators. |
1845
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
If a C<name> attribute isn't provided, a new deflator is created for and |
1847
|
|
|
|
|
|
|
added to every field on the form. |
1848
|
|
|
|
|
|
|
|
1849
|
|
|
|
|
|
|
If you want to load a deflator in a namespace other than |
1850
|
|
|
|
|
|
|
C<HTML::FormFu::Deflator::>, you can use a fully qualified package-name by |
1851
|
|
|
|
|
|
|
prefixing it with C<+>. |
1852
|
|
|
|
|
|
|
|
1853
|
|
|
|
|
|
|
L</deflator> is an alias for L</deflators>. |
1854
|
|
|
|
|
|
|
|
1855
|
|
|
|
|
|
|
=head2 insert_before |
1856
|
|
|
|
|
|
|
|
1857
|
|
|
|
|
|
|
Arguments: $new_element, $existing_element |
1858
|
|
|
|
|
|
|
|
1859
|
|
|
|
|
|
|
Return Value: $new_element |
1860
|
|
|
|
|
|
|
|
1861
|
|
|
|
|
|
|
The 1st argument must be the element you want added, the 2nd argument |
1862
|
|
|
|
|
|
|
must be the existing element that the new element should be placed before. |
1863
|
|
|
|
|
|
|
|
1864
|
|
|
|
|
|
|
my $new = $form->element(\%specs); |
1865
|
|
|
|
|
|
|
|
1866
|
|
|
|
|
|
|
my $position = $form->get_element({ type => $type, name => $name }); |
1867
|
|
|
|
|
|
|
|
1868
|
|
|
|
|
|
|
$form->insert_before( $new, $position ); |
1869
|
|
|
|
|
|
|
|
1870
|
|
|
|
|
|
|
In the first line of the above example, the C<$new> element is initially |
1871
|
|
|
|
|
|
|
added to the end of the form. However, the C<insert_before> method |
1872
|
|
|
|
|
|
|
reparents the C<$new> element, so it will no longer be on the end of the |
1873
|
|
|
|
|
|
|
form. Because of this, if you try to copy an element from one form to |
1874
|
|
|
|
|
|
|
another, it will 'steal' the element, instead of copying it. In this case, |
1875
|
|
|
|
|
|
|
you must use C<clone>: |
1876
|
|
|
|
|
|
|
|
1877
|
|
|
|
|
|
|
my $new = $form1->get_element({ type => $type1, name => $name1 }) |
1878
|
|
|
|
|
|
|
->clone; |
1879
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
my $position = $form2->get_element({ type => $type2, name => $name2 }); |
1881
|
|
|
|
|
|
|
|
1882
|
|
|
|
|
|
|
$form2->insert_before( $new, $position ); |
1883
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
=head2 insert_after |
1885
|
|
|
|
|
|
|
|
1886
|
|
|
|
|
|
|
Arguments: $new_element, $existing_element |
1887
|
|
|
|
|
|
|
|
1888
|
|
|
|
|
|
|
Return Value: $new_element |
1889
|
|
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
The 1st argument must be the element you want added, the 2nd argument |
1891
|
|
|
|
|
|
|
must be the existing element that the new element should be placed after. |
1892
|
|
|
|
|
|
|
|
1893
|
|
|
|
|
|
|
my $new = $form->element(\%specs); |
1894
|
|
|
|
|
|
|
|
1895
|
|
|
|
|
|
|
my $position = $form->get_element({ type => $type, name => $name }); |
1896
|
|
|
|
|
|
|
|
1897
|
|
|
|
|
|
|
$form->insert_after( $new, $position ); |
1898
|
|
|
|
|
|
|
|
1899
|
|
|
|
|
|
|
In the first line of the above example, the C<$new> element is initially |
1900
|
|
|
|
|
|
|
added to the end of the form. However, the C<insert_after> method |
1901
|
|
|
|
|
|
|
reparents the C<$new> element, so it will no longer be on the end of the |
1902
|
|
|
|
|
|
|
form. Because of this, if you try to copy an element from one form to |
1903
|
|
|
|
|
|
|
another, it will 'steal' the element, instead of copying it. In this case, |
1904
|
|
|
|
|
|
|
you must use C<clone>: |
1905
|
|
|
|
|
|
|
|
1906
|
|
|
|
|
|
|
my $new = $form1->get_element({ type => $type1, name => $name1 }) |
1907
|
|
|
|
|
|
|
->clone; |
1908
|
|
|
|
|
|
|
|
1909
|
|
|
|
|
|
|
my $position = $form2->get_element({ type => $type2, name => $name2 }); |
1910
|
|
|
|
|
|
|
|
1911
|
|
|
|
|
|
|
$form2->insert_after( $new, $position ); |
1912
|
|
|
|
|
|
|
|
1913
|
|
|
|
|
|
|
=head2 remove_element |
1914
|
|
|
|
|
|
|
|
1915
|
|
|
|
|
|
|
Arguments: $element |
1916
|
|
|
|
|
|
|
|
1917
|
|
|
|
|
|
|
Return Value: $element |
1918
|
|
|
|
|
|
|
|
1919
|
|
|
|
|
|
|
Removes the C<$element> from the form or block's array of children. |
1920
|
|
|
|
|
|
|
|
1921
|
|
|
|
|
|
|
$form->remove_element( $element ); |
1922
|
|
|
|
|
|
|
|
1923
|
|
|
|
|
|
|
The orphaned element cannot be usefully used for anything until it is |
1924
|
|
|
|
|
|
|
re-attached to a form or block with L</insert_before> or L</insert_after>. |
1925
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
=head1 FORM LOGIC AND VALIDATION |
1927
|
|
|
|
|
|
|
|
1928
|
|
|
|
|
|
|
L<HTML::FormFu|HTML::FormFu> provides several stages for what is |
1929
|
|
|
|
|
|
|
traditionally described as I<validation>. These are: |
1930
|
|
|
|
|
|
|
|
1931
|
|
|
|
|
|
|
=over |
1932
|
|
|
|
|
|
|
|
1933
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter|HTML::FormFu::Filter> |
1934
|
|
|
|
|
|
|
|
1935
|
|
|
|
|
|
|
=item L<HTML::FormFu::Constraint|HTML::FormFu::Constraint> |
1936
|
|
|
|
|
|
|
|
1937
|
|
|
|
|
|
|
=item L<HTML::FormFu::Inflator|HTML::FormFu::Inflator> |
1938
|
|
|
|
|
|
|
|
1939
|
|
|
|
|
|
|
=item L<HTML::FormFu::Validator|HTML::FormFu::Validator> |
1940
|
|
|
|
|
|
|
|
1941
|
|
|
|
|
|
|
=item L<HTML::FormFu::Transformer|HTML::FormFu::Transformer> |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
=back |
1944
|
|
|
|
|
|
|
|
1945
|
|
|
|
|
|
|
The first stage, the filters, allow for cleanup of user-input, such as |
1946
|
|
|
|
|
|
|
encoding, or removing leading/trailing whitespace, or removing non-digit |
1947
|
|
|
|
|
|
|
characters from a creditcard number. |
1948
|
|
|
|
|
|
|
|
1949
|
|
|
|
|
|
|
All of the following stages allow for more complex processing, and each of |
1950
|
|
|
|
|
|
|
them have a mechanism to allow exceptions to be thrown, to represent input |
1951
|
|
|
|
|
|
|
errors. In each stage, all form fields must be processed without error for |
1952
|
|
|
|
|
|
|
the next stage to proceed. If there were any errors, the form should be |
1953
|
|
|
|
|
|
|
re-displayed to the user, to allow them to input correct values. |
1954
|
|
|
|
|
|
|
|
1955
|
|
|
|
|
|
|
Constraints are intended for low-level validation of values, such as |
1956
|
|
|
|
|
|
|
"is this an integer?", "is this value within bounds?" or |
1957
|
|
|
|
|
|
|
"is this a valid email address?". |
1958
|
|
|
|
|
|
|
|
1959
|
|
|
|
|
|
|
Inflators are intended to allow a value to be turned into an appropriate |
1960
|
|
|
|
|
|
|
object. The resulting object will be passed to subsequent Validators and |
1961
|
|
|
|
|
|
|
Transformers, and will also be returned by L</params> and L</param>. |
1962
|
|
|
|
|
|
|
|
1963
|
|
|
|
|
|
|
Validators are intended for higher-level validation, such as |
1964
|
|
|
|
|
|
|
business-logic and database constraints such as "is this username unique?". |
1965
|
|
|
|
|
|
|
Validators are only run if all Constraints and Inflators have run |
1966
|
|
|
|
|
|
|
without errors. It is expected that most Validators will be |
1967
|
|
|
|
|
|
|
application-specific, and so each will be implemented as a separate class |
1968
|
|
|
|
|
|
|
written by the HTML::FormFu user. |
1969
|
|
|
|
|
|
|
|
1970
|
|
|
|
|
|
|
=head2 filters |
1971
|
|
|
|
|
|
|
|
1972
|
|
|
|
|
|
|
=head2 filter |
1973
|
|
|
|
|
|
|
|
1974
|
|
|
|
|
|
|
Arguments: $type |
1975
|
|
|
|
|
|
|
|
1976
|
|
|
|
|
|
|
Arguments: \%options |
1977
|
|
|
|
|
|
|
|
1978
|
|
|
|
|
|
|
Return Value: $filter |
1979
|
|
|
|
|
|
|
|
1980
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
1981
|
|
|
|
|
|
|
|
1982
|
|
|
|
|
|
|
Return Value: @filters |
1983
|
|
|
|
|
|
|
|
1984
|
|
|
|
|
|
|
If you provide a C<name> or C<names> value, the filter will be added to |
1985
|
|
|
|
|
|
|
just that named field. |
1986
|
|
|
|
|
|
|
If you do not provide a C<name> or C<names> value, the filter will be added |
1987
|
|
|
|
|
|
|
to all L<fields|HTML::FormFu::Role::Element::Field> already attached to the form. |
1988
|
|
|
|
|
|
|
|
1989
|
|
|
|
|
|
|
See L<HTML::FormFu::Filter/"CORE FILTERS"> for a list of core filters. |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
If you want to load a filter in a namespace other than |
1992
|
|
|
|
|
|
|
C<HTML::FormFu::Filter::>, you can use a fully qualified package-name by |
1993
|
|
|
|
|
|
|
prefixing it with C<+>. |
1994
|
|
|
|
|
|
|
|
1995
|
|
|
|
|
|
|
L</filter> is an alias for L</filters>. |
1996
|
|
|
|
|
|
|
|
1997
|
|
|
|
|
|
|
=head2 constraints |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
=head2 constraint |
2000
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
Arguments: $type |
2002
|
|
|
|
|
|
|
|
2003
|
|
|
|
|
|
|
Arguments: \%options |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
Return Value: $constraint |
2006
|
|
|
|
|
|
|
|
2007
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
2008
|
|
|
|
|
|
|
|
2009
|
|
|
|
|
|
|
Return Value: @constraints |
2010
|
|
|
|
|
|
|
|
2011
|
|
|
|
|
|
|
See L<HTML::FormFu::Constraint/"CORE CONSTRAINTS"> for a list of core |
2012
|
|
|
|
|
|
|
constraints. |
2013
|
|
|
|
|
|
|
|
2014
|
|
|
|
|
|
|
If a C<name> attribute isn't provided, a new constraint is created for and |
2015
|
|
|
|
|
|
|
added to every field on the form. |
2016
|
|
|
|
|
|
|
|
2017
|
|
|
|
|
|
|
If you want to load a constraint in a namespace other than |
2018
|
|
|
|
|
|
|
C<HTML::FormFu::Constraint::>, you can use a fully qualified package-name by |
2019
|
|
|
|
|
|
|
prefixing it with C<+>. |
2020
|
|
|
|
|
|
|
|
2021
|
|
|
|
|
|
|
L</constraint> is an alias for L</constraints>. |
2022
|
|
|
|
|
|
|
|
2023
|
|
|
|
|
|
|
=head2 inflators |
2024
|
|
|
|
|
|
|
|
2025
|
|
|
|
|
|
|
=head2 inflator |
2026
|
|
|
|
|
|
|
|
2027
|
|
|
|
|
|
|
Arguments: $type |
2028
|
|
|
|
|
|
|
|
2029
|
|
|
|
|
|
|
Arguments: \%options |
2030
|
|
|
|
|
|
|
|
2031
|
|
|
|
|
|
|
Return Value: $inflator |
2032
|
|
|
|
|
|
|
|
2033
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
2034
|
|
|
|
|
|
|
|
2035
|
|
|
|
|
|
|
Return Value: @inflators |
2036
|
|
|
|
|
|
|
|
2037
|
|
|
|
|
|
|
See L<HTML::FormFu::Inflator/"CORE INFLATORS"> for a list of core inflators. |
2038
|
|
|
|
|
|
|
|
2039
|
|
|
|
|
|
|
If a C<name> attribute isn't provided, a new inflator is created for and |
2040
|
|
|
|
|
|
|
added to every field on the form. |
2041
|
|
|
|
|
|
|
|
2042
|
|
|
|
|
|
|
If you want to load an inflator in a namespace other than |
2043
|
|
|
|
|
|
|
C<HTML::FormFu::Inflator::>, you can use a fully qualified package-name by |
2044
|
|
|
|
|
|
|
prefixing it with C<+>. |
2045
|
|
|
|
|
|
|
|
2046
|
|
|
|
|
|
|
L</inflator> is an alias for L</inflators>. |
2047
|
|
|
|
|
|
|
|
2048
|
|
|
|
|
|
|
=head2 validators |
2049
|
|
|
|
|
|
|
|
2050
|
|
|
|
|
|
|
=head2 validator |
2051
|
|
|
|
|
|
|
|
2052
|
|
|
|
|
|
|
Arguments: $type |
2053
|
|
|
|
|
|
|
|
2054
|
|
|
|
|
|
|
Arguments: \%options |
2055
|
|
|
|
|
|
|
|
2056
|
|
|
|
|
|
|
Return Value: $validator |
2057
|
|
|
|
|
|
|
|
2058
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
2059
|
|
|
|
|
|
|
|
2060
|
|
|
|
|
|
|
Return Value: @validators |
2061
|
|
|
|
|
|
|
|
2062
|
|
|
|
|
|
|
See L<HTML::FormFu::Validator/"CORE VALIDATORS"> for a list of core |
2063
|
|
|
|
|
|
|
validators. |
2064
|
|
|
|
|
|
|
|
2065
|
|
|
|
|
|
|
If a C<name> attribute isn't provided, a new validator is created for and |
2066
|
|
|
|
|
|
|
added to every field on the form. |
2067
|
|
|
|
|
|
|
|
2068
|
|
|
|
|
|
|
If you want to load a validator in a namespace other than |
2069
|
|
|
|
|
|
|
C<HTML::FormFu::Validator::>, you can use a fully qualified package-name by |
2070
|
|
|
|
|
|
|
prefixing it with C<+>. |
2071
|
|
|
|
|
|
|
|
2072
|
|
|
|
|
|
|
L</validator> is an alias for L</validators>. |
2073
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
=head2 transformers |
2075
|
|
|
|
|
|
|
|
2076
|
|
|
|
|
|
|
=head2 transformer |
2077
|
|
|
|
|
|
|
|
2078
|
|
|
|
|
|
|
Arguments: $type |
2079
|
|
|
|
|
|
|
|
2080
|
|
|
|
|
|
|
Arguments: \%options |
2081
|
|
|
|
|
|
|
|
2082
|
|
|
|
|
|
|
Return Value: $transformer |
2083
|
|
|
|
|
|
|
|
2084
|
|
|
|
|
|
|
Arguments: \@arrayref_of_types_or_options |
2085
|
|
|
|
|
|
|
|
2086
|
|
|
|
|
|
|
Return Value: @transformers |
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
See L<HTML::FormFu::Transformer/"CORE TRANSFORMERS"> for a list of core |
2089
|
|
|
|
|
|
|
transformers. |
2090
|
|
|
|
|
|
|
|
2091
|
|
|
|
|
|
|
If a C<name> attribute isn't provided, a new transformer is created for and |
2092
|
|
|
|
|
|
|
added to every field on the form. |
2093
|
|
|
|
|
|
|
|
2094
|
|
|
|
|
|
|
If you want to load a transformer in a namespace other than |
2095
|
|
|
|
|
|
|
C<HTML::FormFu::Transformer::>, you can use a fully qualified package-name by |
2096
|
|
|
|
|
|
|
prefixing it with C<+>. |
2097
|
|
|
|
|
|
|
|
2098
|
|
|
|
|
|
|
L</transformer> is an alias for L</transformers>. |
2099
|
|
|
|
|
|
|
|
2100
|
|
|
|
|
|
|
=head1 CHANGING DEFAULT BEHAVIOUR |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
=head2 render_processed_value |
2103
|
|
|
|
|
|
|
|
2104
|
|
|
|
|
|
|
The default behaviour when re-displaying a form after a submission, is that |
2105
|
|
|
|
|
|
|
the field contains the original unchanged user-submitted value. |
2106
|
|
|
|
|
|
|
|
2107
|
|
|
|
|
|
|
If L</render_processed_value> is true, the field value will be the final |
2108
|
|
|
|
|
|
|
result after all Filters, Inflators and Transformers have been run. |
2109
|
|
|
|
|
|
|
Deflators will also be run on the value. |
2110
|
|
|
|
|
|
|
|
2111
|
|
|
|
|
|
|
If you set this on a field with an Inflator, but without an equivalent |
2112
|
|
|
|
|
|
|
Deflator, you should ensure that the Inflators stringify back to a usable |
2113
|
|
|
|
|
|
|
value, so as not to confuse / annoy the user. |
2114
|
|
|
|
|
|
|
|
2115
|
|
|
|
|
|
|
Default Value: false |
2116
|
|
|
|
|
|
|
|
2117
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
2118
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
2119
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
2120
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
2121
|
|
|
|
|
|
|
defined value. |
2122
|
|
|
|
|
|
|
|
2123
|
|
|
|
|
|
|
Is an L<inheriting accessor|/INHERITING ACCESSORS>. |
2124
|
|
|
|
|
|
|
|
2125
|
|
|
|
|
|
|
=head2 force_errors |
2126
|
|
|
|
|
|
|
|
2127
|
|
|
|
|
|
|
Force a constraint to fail, regardless of user input. |
2128
|
|
|
|
|
|
|
|
2129
|
|
|
|
|
|
|
If this is called at runtime, after the form has already been processed, |
2130
|
|
|
|
|
|
|
you must called L<HTML::FormFu/process> again before redisplaying the |
2131
|
|
|
|
|
|
|
form to the user. |
2132
|
|
|
|
|
|
|
|
2133
|
|
|
|
|
|
|
Default Value: false |
2134
|
|
|
|
|
|
|
|
2135
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
2136
|
|
|
|
|
|
|
the form, a block element, an element or a single constraint. When the value |
2137
|
|
|
|
|
|
|
is read, if no value is defined it automatically traverses the element's |
2138
|
|
|
|
|
|
|
hierarchy of parents, through any block elements and up to the form, |
2139
|
|
|
|
|
|
|
searching for a defined value. |
2140
|
|
|
|
|
|
|
|
2141
|
|
|
|
|
|
|
Is an L<inheriting accessor|/INHERITING ACCESSORS>. |
2142
|
|
|
|
|
|
|
|
2143
|
|
|
|
|
|
|
=head2 params_ignore_underscore |
2144
|
|
|
|
|
|
|
|
2145
|
|
|
|
|
|
|
If true, causes L</params>, L</param> and L</valid> to ignore any fields |
2146
|
|
|
|
|
|
|
whose name starts with an underscore C<_>. |
2147
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
The field is still processed as normal, and errors will cause |
2149
|
|
|
|
|
|
|
L</submitted_and_valid> to return false. |
2150
|
|
|
|
|
|
|
|
2151
|
|
|
|
|
|
|
Default Value: false |
2152
|
|
|
|
|
|
|
|
2153
|
|
|
|
|
|
|
=head1 FORM ATTRIBUTES |
2154
|
|
|
|
|
|
|
|
2155
|
|
|
|
|
|
|
All attributes are added to the rendered form's start tag. |
2156
|
|
|
|
|
|
|
|
2157
|
|
|
|
|
|
|
=head2 attributes |
2158
|
|
|
|
|
|
|
|
2159
|
|
|
|
|
|
|
# Example |
2160
|
|
|
|
|
|
|
--- |
2161
|
|
|
|
|
|
|
attributes: |
2162
|
|
|
|
|
|
|
id: form |
2163
|
|
|
|
|
|
|
class: fancy_form |
2164
|
|
|
|
|
|
|
|
2165
|
|
|
|
|
|
|
Is an L<attribute accessor|HTML::FormFu/ATTRIBUTE ACCESSOR>. |
2166
|
|
|
|
|
|
|
|
2167
|
|
|
|
|
|
|
=head2 id |
2168
|
|
|
|
|
|
|
|
2169
|
|
|
|
|
|
|
Is an L<attribute short-cut|HTML::FormFu/ATTRIBUTE SHORT-CUTS>. |
2170
|
|
|
|
|
|
|
|
2171
|
|
|
|
|
|
|
=head2 action |
2172
|
|
|
|
|
|
|
|
2173
|
|
|
|
|
|
|
Default Value: "" |
2174
|
|
|
|
|
|
|
|
2175
|
|
|
|
|
|
|
Get or set the action associated with the form. The default is no action, |
2176
|
|
|
|
|
|
|
which causes most browsers to submit to the current URI. |
2177
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
Is an L<attribute short-cut|HTML::FormFu/ATTRIBUTE SHORT-CUTS>. |
2179
|
|
|
|
|
|
|
|
2180
|
|
|
|
|
|
|
=head2 enctype |
2181
|
|
|
|
|
|
|
|
2182
|
|
|
|
|
|
|
Get or set the encoding type of the form. Valid values are |
2183
|
|
|
|
|
|
|
C<application/x-www-form-urlencoded> and C<multipart/form-data>. |
2184
|
|
|
|
|
|
|
|
2185
|
|
|
|
|
|
|
If the form contains a File element, the enctype is automatically set to |
2186
|
|
|
|
|
|
|
C<multipart/form-data>. |
2187
|
|
|
|
|
|
|
|
2188
|
|
|
|
|
|
|
Is an L<attribute short-cut|HTML::FormFu/ATTRIBUTE SHORT-CUTS>. |
2189
|
|
|
|
|
|
|
|
2190
|
|
|
|
|
|
|
=head2 method |
2191
|
|
|
|
|
|
|
|
2192
|
|
|
|
|
|
|
Default Value: "post" |
2193
|
|
|
|
|
|
|
|
2194
|
|
|
|
|
|
|
Get or set the method used to submit the form. Can be set to either "post" |
2195
|
|
|
|
|
|
|
or "get". |
2196
|
|
|
|
|
|
|
|
2197
|
|
|
|
|
|
|
Is an L<attribute short-cut|HTML::FormFu/ATTRIBUTE SHORT-CUTS>. |
2198
|
|
|
|
|
|
|
|
2199
|
|
|
|
|
|
|
=head2 title |
2200
|
|
|
|
|
|
|
|
2201
|
|
|
|
|
|
|
Get or set the form's title attribute. |
2202
|
|
|
|
|
|
|
|
2203
|
|
|
|
|
|
|
Is an L<attribute short-cut|HTML::FormFu/ATTRIBUTE SHORT-CUTS>. |
2204
|
|
|
|
|
|
|
|
2205
|
|
|
|
|
|
|
=head1 CSS CLASSES |
2206
|
|
|
|
|
|
|
|
2207
|
|
|
|
|
|
|
=head2 form_error_message_class |
2208
|
|
|
|
|
|
|
|
2209
|
|
|
|
|
|
|
Class attribute for the error message displayed at the top of the form. |
2210
|
|
|
|
|
|
|
|
2211
|
|
|
|
|
|
|
See L</"form_error_message"> |
2212
|
|
|
|
|
|
|
|
2213
|
|
|
|
|
|
|
=head1 LOCALIZATION |
2214
|
|
|
|
|
|
|
|
2215
|
|
|
|
|
|
|
=head2 languages |
2216
|
|
|
|
|
|
|
|
2217
|
|
|
|
|
|
|
Arguments: [\@languages] |
2218
|
|
|
|
|
|
|
|
2219
|
|
|
|
|
|
|
A list of languages which will be passed to the localization object. |
2220
|
|
|
|
|
|
|
|
2221
|
|
|
|
|
|
|
Default Value: ['en'] |
2222
|
|
|
|
|
|
|
|
2223
|
|
|
|
|
|
|
=head2 localize_class |
2224
|
|
|
|
|
|
|
|
2225
|
|
|
|
|
|
|
Arguments: [$class_name] |
2226
|
|
|
|
|
|
|
|
2227
|
|
|
|
|
|
|
Classname to be used for the default localization object. |
2228
|
|
|
|
|
|
|
|
2229
|
|
|
|
|
|
|
Default Value: 'HTML::FormFu::I18N' |
2230
|
|
|
|
|
|
|
|
2231
|
|
|
|
|
|
|
=head2 localize |
2232
|
|
|
|
|
|
|
|
2233
|
|
|
|
|
|
|
=head2 loc |
2234
|
|
|
|
|
|
|
|
2235
|
|
|
|
|
|
|
Arguments: [$key, @arguments] |
2236
|
|
|
|
|
|
|
|
2237
|
|
|
|
|
|
|
Compatible with the C<maketext> method in L<Locale::Maketext>. |
2238
|
|
|
|
|
|
|
|
2239
|
|
|
|
|
|
|
=head2 locale |
2240
|
|
|
|
|
|
|
|
2241
|
|
|
|
|
|
|
Arguments: $locale |
2242
|
|
|
|
|
|
|
|
2243
|
|
|
|
|
|
|
Currently only used by L<HTML::FormFu::Deflator::FormatNumber> and |
2244
|
|
|
|
|
|
|
L<HTML::FormFu::Filter::FormatNumber>. |
2245
|
|
|
|
|
|
|
|
2246
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
2247
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
2248
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
2249
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
2250
|
|
|
|
|
|
|
defined value. |
2251
|
|
|
|
|
|
|
|
2252
|
|
|
|
|
|
|
Is an L<inheriting accessor|/INHERITING ACCESSORS>. |
2253
|
|
|
|
|
|
|
|
2254
|
|
|
|
|
|
|
=head1 PROCESSING A FORM |
2255
|
|
|
|
|
|
|
|
2256
|
|
|
|
|
|
|
=head2 query |
2257
|
|
|
|
|
|
|
|
2258
|
|
|
|
|
|
|
Arguments: [$query_object] |
2259
|
|
|
|
|
|
|
|
2260
|
|
|
|
|
|
|
Arguments: \%params |
2261
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
Provide a L<CGI> compatible query object or a hash-ref of submitted |
2263
|
|
|
|
|
|
|
names/values. Alternatively, the query object can be passed directly to the |
2264
|
|
|
|
|
|
|
L</process> object. |
2265
|
|
|
|
|
|
|
|
2266
|
|
|
|
|
|
|
=head2 query_type |
2267
|
|
|
|
|
|
|
|
2268
|
|
|
|
|
|
|
Arguments: [$query_type] |
2269
|
|
|
|
|
|
|
|
2270
|
|
|
|
|
|
|
Set which module is being used to provide the L</query>. |
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
The L<Catalyst::Controller::HTML::FormFu> automatically sets this to |
2273
|
|
|
|
|
|
|
C<Catalyst>. |
2274
|
|
|
|
|
|
|
|
2275
|
|
|
|
|
|
|
Valid values are C<CGI>, C<Catalyst> and C<CGI::Simple>. |
2276
|
|
|
|
|
|
|
|
2277
|
|
|
|
|
|
|
Default Value: 'CGI' |
2278
|
|
|
|
|
|
|
|
2279
|
|
|
|
|
|
|
=head2 process |
2280
|
|
|
|
|
|
|
|
2281
|
|
|
|
|
|
|
Arguments: [$query_object] |
2282
|
|
|
|
|
|
|
|
2283
|
|
|
|
|
|
|
Arguments: [\%params] |
2284
|
|
|
|
|
|
|
|
2285
|
|
|
|
|
|
|
Process the provided query object or input values. C<process> must be called |
2286
|
|
|
|
|
|
|
before calling any of the methods listed under |
2287
|
|
|
|
|
|
|
L</"SUBMITTED FORM VALUES AND ERRORS"> and L</"MODIFYING A SUBMITTED FORM">. |
2288
|
|
|
|
|
|
|
|
2289
|
|
|
|
|
|
|
C<process> must also be called at least once before printing the form or |
2290
|
|
|
|
|
|
|
calling L</render> or L</render_data>. |
2291
|
|
|
|
|
|
|
|
2292
|
|
|
|
|
|
|
Note to users of L<Catalyst::Controller::HTML::FormFu>: Because L</process> |
2293
|
|
|
|
|
|
|
is automatically called for you by the Catalyst controller; if you make any |
2294
|
|
|
|
|
|
|
modifications to the form within your action method, such as adding or changing |
2295
|
|
|
|
|
|
|
elements, adding constraints, etc; you must call L</process> again yourself |
2296
|
|
|
|
|
|
|
before using L</submitted_and_valid>, any of the methods listed under |
2297
|
|
|
|
|
|
|
L</"SUBMITTED FORM VALUES AND ERRORS"> or |
2298
|
|
|
|
|
|
|
L</"MODIFYING A SUBMITTED FORM">, or rendering the form. |
2299
|
|
|
|
|
|
|
|
2300
|
|
|
|
|
|
|
=head1 SUBMITTED FORM VALUES AND ERRORS |
2301
|
|
|
|
|
|
|
|
2302
|
|
|
|
|
|
|
=head2 submitted |
2303
|
|
|
|
|
|
|
|
2304
|
|
|
|
|
|
|
Returns true if the form has been submitted. See L</indicator> for details |
2305
|
|
|
|
|
|
|
on how this is computed. |
2306
|
|
|
|
|
|
|
|
2307
|
|
|
|
|
|
|
=head2 submitted_and_valid |
2308
|
|
|
|
|
|
|
|
2309
|
|
|
|
|
|
|
Shorthand for C<< $form->submitted && !$form->has_errors >> |
2310
|
|
|
|
|
|
|
|
2311
|
|
|
|
|
|
|
=head2 params |
2312
|
|
|
|
|
|
|
|
2313
|
|
|
|
|
|
|
Return Value: \%params |
2314
|
|
|
|
|
|
|
|
2315
|
|
|
|
|
|
|
Returns a hash-ref of all valid input for which there were no errors. |
2316
|
|
|
|
|
|
|
|
2317
|
|
|
|
|
|
|
=head2 param_value |
2318
|
|
|
|
|
|
|
|
2319
|
|
|
|
|
|
|
Arguments: $field_name |
2320
|
|
|
|
|
|
|
|
2321
|
|
|
|
|
|
|
A more reliable, recommended version of L</param>. Guaranteed to always return a |
2322
|
|
|
|
|
|
|
single value, regardless of whether it's called in list context or not. If |
2323
|
|
|
|
|
|
|
multiple values were submitted, this only returns the first value. If the value |
2324
|
|
|
|
|
|
|
is invalid or the form was not submitted, it returns C<undef>. This makes it |
2325
|
|
|
|
|
|
|
suitable for use in list context, where a single value is required. |
2326
|
|
|
|
|
|
|
|
2327
|
|
|
|
|
|
|
$db->update({ |
2328
|
|
|
|
|
|
|
name => $form->param_value('name'), |
2329
|
|
|
|
|
|
|
address => $form->param_value('address), |
2330
|
|
|
|
|
|
|
}); |
2331
|
|
|
|
|
|
|
|
2332
|
|
|
|
|
|
|
=head2 param_array |
2333
|
|
|
|
|
|
|
|
2334
|
|
|
|
|
|
|
Arguments: $field_name |
2335
|
|
|
|
|
|
|
|
2336
|
|
|
|
|
|
|
Guaranteed to always return an array-ref of values, regardless of context and |
2337
|
|
|
|
|
|
|
regardless of whether multiple values were submitted or not. If the value is |
2338
|
|
|
|
|
|
|
invalid or the form was not submitted, it returns an empty array-ref. |
2339
|
|
|
|
|
|
|
|
2340
|
|
|
|
|
|
|
=head2 param_list |
2341
|
|
|
|
|
|
|
|
2342
|
|
|
|
|
|
|
Arguments: $field_name |
2343
|
|
|
|
|
|
|
|
2344
|
|
|
|
|
|
|
Guaranteed to always return a list of values, regardless of context. If the value is |
2345
|
|
|
|
|
|
|
invalid or the form was not submitted, it returns an empty list. |
2346
|
|
|
|
|
|
|
|
2347
|
|
|
|
|
|
|
=head2 param |
2348
|
|
|
|
|
|
|
|
2349
|
|
|
|
|
|
|
Arguments: [$field_name] |
2350
|
|
|
|
|
|
|
|
2351
|
|
|
|
|
|
|
Return Value: $input_value |
2352
|
|
|
|
|
|
|
|
2353
|
|
|
|
|
|
|
Return Value: @valid_names |
2354
|
|
|
|
|
|
|
|
2355
|
|
|
|
|
|
|
No longer recommended for use, as its behaviour is hard to predict. Use |
2356
|
|
|
|
|
|
|
L</param_value>, L</param_array> or L</param_list> instead. |
2357
|
|
|
|
|
|
|
|
2358
|
|
|
|
|
|
|
A (readonly) method similar to that of L<CGI's|CGI>. |
2359
|
|
|
|
|
|
|
|
2360
|
|
|
|
|
|
|
If a field name is given, in list-context returns any valid values submitted |
2361
|
|
|
|
|
|
|
for that field, and in scalar-context returns only the first of any valid |
2362
|
|
|
|
|
|
|
values submitted for that field. |
2363
|
|
|
|
|
|
|
|
2364
|
|
|
|
|
|
|
If no argument is given, returns a list of all valid input field names |
2365
|
|
|
|
|
|
|
without errors. |
2366
|
|
|
|
|
|
|
|
2367
|
|
|
|
|
|
|
Passing more than 1 argument is a fatal error. |
2368
|
|
|
|
|
|
|
|
2369
|
|
|
|
|
|
|
=head2 valid |
2370
|
|
|
|
|
|
|
|
2371
|
|
|
|
|
|
|
Arguments: [$field_name] |
2372
|
|
|
|
|
|
|
|
2373
|
|
|
|
|
|
|
Return Value: @valid_names |
2374
|
|
|
|
|
|
|
|
2375
|
|
|
|
|
|
|
Return Value: $bool |
2376
|
|
|
|
|
|
|
|
2377
|
|
|
|
|
|
|
If a field name if given, returns C<true> if that field had no errors and |
2378
|
|
|
|
|
|
|
C<false> if there were errors. |
2379
|
|
|
|
|
|
|
|
2380
|
|
|
|
|
|
|
If no argument is given, returns a list of all valid input field names |
2381
|
|
|
|
|
|
|
without errors. |
2382
|
|
|
|
|
|
|
|
2383
|
|
|
|
|
|
|
=head2 has_errors |
2384
|
|
|
|
|
|
|
|
2385
|
|
|
|
|
|
|
Arguments: [$field_name] |
2386
|
|
|
|
|
|
|
|
2387
|
|
|
|
|
|
|
Return Value: @names |
2388
|
|
|
|
|
|
|
|
2389
|
|
|
|
|
|
|
Return Value: $bool |
2390
|
|
|
|
|
|
|
|
2391
|
|
|
|
|
|
|
If a field name if given, returns C<true> if that field had errors and |
2392
|
|
|
|
|
|
|
C<false> if there were no errors. |
2393
|
|
|
|
|
|
|
|
2394
|
|
|
|
|
|
|
If no argument is given, returns a list of all input field names with errors. |
2395
|
|
|
|
|
|
|
|
2396
|
|
|
|
|
|
|
=head2 get_errors |
2397
|
|
|
|
|
|
|
|
2398
|
|
|
|
|
|
|
Arguments: [%options] |
2399
|
|
|
|
|
|
|
|
2400
|
|
|
|
|
|
|
Arguments: [\%options] |
2401
|
|
|
|
|
|
|
|
2402
|
|
|
|
|
|
|
Return Value: \@errors |
2403
|
|
|
|
|
|
|
|
2404
|
|
|
|
|
|
|
Returns an array-ref of exception objects from all fields in the form. |
2405
|
|
|
|
|
|
|
|
2406
|
|
|
|
|
|
|
Accepts both C<name>, C<type> and C<stage> arguments to narrow the returned |
2407
|
|
|
|
|
|
|
results. |
2408
|
|
|
|
|
|
|
|
2409
|
|
|
|
|
|
|
$form->get_errors({ |
2410
|
|
|
|
|
|
|
name => 'foo', |
2411
|
|
|
|
|
|
|
type => 'Regex', |
2412
|
|
|
|
|
|
|
stage => 'constraint' |
2413
|
|
|
|
|
|
|
}); |
2414
|
|
|
|
|
|
|
|
2415
|
|
|
|
|
|
|
=head2 get_error |
2416
|
|
|
|
|
|
|
|
2417
|
|
|
|
|
|
|
Arguments: [%options] |
2418
|
|
|
|
|
|
|
|
2419
|
|
|
|
|
|
|
Arguments: [\%options] |
2420
|
|
|
|
|
|
|
|
2421
|
|
|
|
|
|
|
Return Value: $error |
2422
|
|
|
|
|
|
|
|
2423
|
|
|
|
|
|
|
Accepts the same arguments as L</get_errors>, but only returns the first |
2424
|
|
|
|
|
|
|
error found. |
2425
|
|
|
|
|
|
|
|
2426
|
|
|
|
|
|
|
=head1 MODEL / DATABASE INTERACTION |
2427
|
|
|
|
|
|
|
|
2428
|
|
|
|
|
|
|
See L<HTML::FormFu::Model> for further details and available models. |
2429
|
|
|
|
|
|
|
|
2430
|
|
|
|
|
|
|
=head2 default_model |
2431
|
|
|
|
|
|
|
|
2432
|
|
|
|
|
|
|
Arguments: $model_name |
2433
|
|
|
|
|
|
|
|
2434
|
|
|
|
|
|
|
Default Value: 'DBIC' |
2435
|
|
|
|
|
|
|
|
2436
|
|
|
|
|
|
|
=head2 model |
2437
|
|
|
|
|
|
|
|
2438
|
|
|
|
|
|
|
Arguments: [$model_name] |
2439
|
|
|
|
|
|
|
|
2440
|
|
|
|
|
|
|
Return Value: $model |
2441
|
|
|
|
|
|
|
|
2442
|
|
|
|
|
|
|
=head2 model_config |
2443
|
|
|
|
|
|
|
|
2444
|
|
|
|
|
|
|
Arguments: \%config |
2445
|
|
|
|
|
|
|
|
2446
|
|
|
|
|
|
|
=head1 MODIFYING A SUBMITTED FORM |
2447
|
|
|
|
|
|
|
|
2448
|
|
|
|
|
|
|
=head2 add_valid |
2449
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
Arguments: $name, $value |
2451
|
|
|
|
|
|
|
|
2452
|
|
|
|
|
|
|
Return Value: $value |
2453
|
|
|
|
|
|
|
|
2454
|
|
|
|
|
|
|
The provided value replaces any current value for the named field. This |
2455
|
|
|
|
|
|
|
value will be returned in subsequent calls to L</params> and L</param> and |
2456
|
|
|
|
|
|
|
the named field will be included in calculations for L</valid>. |
2457
|
|
|
|
|
|
|
|
2458
|
|
|
|
|
|
|
=head2 clear_errors |
2459
|
|
|
|
|
|
|
|
2460
|
|
|
|
|
|
|
Deletes all errors from a submitted form. |
2461
|
|
|
|
|
|
|
|
2462
|
|
|
|
|
|
|
=head1 RENDERING A FORM |
2463
|
|
|
|
|
|
|
|
2464
|
|
|
|
|
|
|
=head2 render |
2465
|
|
|
|
|
|
|
|
2466
|
|
|
|
|
|
|
Return Value: $string |
2467
|
|
|
|
|
|
|
|
2468
|
|
|
|
|
|
|
You must call L</process> once after building the form, and before calling |
2469
|
|
|
|
|
|
|
L</render>. |
2470
|
|
|
|
|
|
|
|
2471
|
|
|
|
|
|
|
=head2 start |
2472
|
|
|
|
|
|
|
|
2473
|
|
|
|
|
|
|
Return Value: $string |
2474
|
|
|
|
|
|
|
|
2475
|
|
|
|
|
|
|
Returns the form start tag, and any output of L</form_error_message> and |
2476
|
|
|
|
|
|
|
L</javascript>. |
2477
|
|
|
|
|
|
|
|
2478
|
|
|
|
|
|
|
=head2 end |
2479
|
|
|
|
|
|
|
|
2480
|
|
|
|
|
|
|
Return Value: $string |
2481
|
|
|
|
|
|
|
|
2482
|
|
|
|
|
|
|
Returns the form end tag. |
2483
|
|
|
|
|
|
|
|
2484
|
|
|
|
|
|
|
=head2 hidden_fields |
2485
|
|
|
|
|
|
|
|
2486
|
|
|
|
|
|
|
Return Value: $string |
2487
|
|
|
|
|
|
|
|
2488
|
|
|
|
|
|
|
Returns all hidden form fields. |
2489
|
|
|
|
|
|
|
|
2490
|
|
|
|
|
|
|
=head1 PLUGIN SYSTEM |
2491
|
|
|
|
|
|
|
|
2492
|
|
|
|
|
|
|
C<HTML::FormFu> provides a plugin-system that allows plugins to be easily |
2493
|
|
|
|
|
|
|
added to a form or element, to change the default behaviour or output. |
2494
|
|
|
|
|
|
|
|
2495
|
|
|
|
|
|
|
See L<HTML::FormFu::Plugin> for details. |
2496
|
|
|
|
|
|
|
|
2497
|
|
|
|
|
|
|
=head1 ADVANCED CUSTOMISATION |
2498
|
|
|
|
|
|
|
|
2499
|
|
|
|
|
|
|
By default, formfu renders "XHTML 1.0 Strict" compliant markup, with as |
2500
|
|
|
|
|
|
|
little extra markup as possible. Many hooks are provided to add |
2501
|
|
|
|
|
|
|
programatically-generated CSS class names, to allow for a wide-range of |
2502
|
|
|
|
|
|
|
output styles to be generated by changing only the CSS. |
2503
|
|
|
|
|
|
|
|
2504
|
|
|
|
|
|
|
Basic customisation of the markup is possible via the |
2505
|
|
|
|
|
|
|
L<layout|HTML::FormFu::Role::Element::Field/layout> and |
2506
|
|
|
|
|
|
|
L<multi_layout|HTML::FormFu::Role::Element::Field/multi_layout> methods. |
2507
|
|
|
|
|
|
|
This allows you to reorder the position of various parts of each field - |
2508
|
|
|
|
|
|
|
such as the label, comment, error messages and the input tag - as well |
2509
|
|
|
|
|
|
|
as inserting any other arbitrary tags you may wish. |
2510
|
|
|
|
|
|
|
|
2511
|
|
|
|
|
|
|
If this is not sufficient, you can make completely personalise the markup |
2512
|
|
|
|
|
|
|
by telling HTML::FormFu to use an external rendering engine, such as |
2513
|
|
|
|
|
|
|
L<Template Toolkit|Template> or L<Template::Alloy>. |
2514
|
|
|
|
|
|
|
See L</render_method> and L</tt_module> for details. |
2515
|
|
|
|
|
|
|
|
2516
|
|
|
|
|
|
|
Even if you set HTML::FormFu to use L<Template::Toolkit|Template> to render, |
2517
|
|
|
|
|
|
|
the forms, HTML::FormFu can still be used in conjunction with whichever other |
2518
|
|
|
|
|
|
|
templating system you prefer to use for your own page layouts, whether it's |
2519
|
|
|
|
|
|
|
L<HTML::Template>: C<< <TMPL_VAR form> >>, |
2520
|
|
|
|
|
|
|
L<Petal>: C<< <form tal:replace="form"></form> >> |
2521
|
|
|
|
|
|
|
or L<Template::Magic>: C<< <!-- {form} --> >>. |
2522
|
|
|
|
|
|
|
|
2523
|
|
|
|
|
|
|
As of C<HTML::FormFu v1.00>, L<TT|Template> is no longer listed a required |
2524
|
|
|
|
|
|
|
prerequisite - so you'll need to install it manually if you with to use the |
2525
|
|
|
|
|
|
|
template files. |
2526
|
|
|
|
|
|
|
|
2527
|
|
|
|
|
|
|
=head2 render_method |
2528
|
|
|
|
|
|
|
|
2529
|
|
|
|
|
|
|
Default Value: C<string> |
2530
|
|
|
|
|
|
|
|
2531
|
|
|
|
|
|
|
Can be set to C<tt> to generate the form with external template files. |
2532
|
|
|
|
|
|
|
|
2533
|
|
|
|
|
|
|
To customise the markup, you'll need a copy of the template files, local to |
2534
|
|
|
|
|
|
|
your application. See |
2535
|
|
|
|
|
|
|
L<HTML::FormFu::Manual::Cookbook/"Installing the TT templates"> for further |
2536
|
|
|
|
|
|
|
details. |
2537
|
|
|
|
|
|
|
|
2538
|
|
|
|
|
|
|
You can customise the markup for a single element by setting that element's |
2539
|
|
|
|
|
|
|
L</render_method> to C<tt>, while the rest of the form uses the default |
2540
|
|
|
|
|
|
|
C<string> render-method. Note though, that if you try setting the form or a |
2541
|
|
|
|
|
|
|
Block's L</render_method> to C<tt>, and then set a child element's |
2542
|
|
|
|
|
|
|
L</render_method> to C<string>, that setting will be ignored, and the child |
2543
|
|
|
|
|
|
|
elements will still use the C<tt> render-method. |
2544
|
|
|
|
|
|
|
|
2545
|
|
|
|
|
|
|
--- |
2546
|
|
|
|
|
|
|
elements: |
2547
|
|
|
|
|
|
|
- name: foo |
2548
|
|
|
|
|
|
|
render_method: tt |
2549
|
|
|
|
|
|
|
filename: custom_field |
2550
|
|
|
|
|
|
|
|
2551
|
|
|
|
|
|
|
- name: bar |
2552
|
|
|
|
|
|
|
|
2553
|
|
|
|
|
|
|
# in this example, 'foo' will use a custom template, |
2554
|
|
|
|
|
|
|
# while bar will use the default 'string' rendering method |
2555
|
|
|
|
|
|
|
|
2556
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
2557
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
2558
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
2559
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
2560
|
|
|
|
|
|
|
defined value. |
2561
|
|
|
|
|
|
|
|
2562
|
|
|
|
|
|
|
Is an L<inheriting accessor|/INHERITING ACCESSORS>. |
2563
|
|
|
|
|
|
|
|
2564
|
|
|
|
|
|
|
=head2 filename |
2565
|
|
|
|
|
|
|
|
2566
|
|
|
|
|
|
|
Change the template filename used for the form. |
2567
|
|
|
|
|
|
|
|
2568
|
|
|
|
|
|
|
Default Value: "form" |
2569
|
|
|
|
|
|
|
|
2570
|
|
|
|
|
|
|
=head2 tt_args |
2571
|
|
|
|
|
|
|
|
2572
|
|
|
|
|
|
|
Arguments: [\%constructor_arguments] |
2573
|
|
|
|
|
|
|
|
2574
|
|
|
|
|
|
|
Accepts a hash-ref of arguments passed to L</render_method>, which is called |
2575
|
|
|
|
|
|
|
internally by L</render>. |
2576
|
|
|
|
|
|
|
|
2577
|
|
|
|
|
|
|
Within tt_args, the keys C<RELATIVE> and C<RECURSION> are overridden to always |
2578
|
|
|
|
|
|
|
be true, as these are a basic requirement for the L<Template> engine. |
2579
|
|
|
|
|
|
|
|
2580
|
|
|
|
|
|
|
The system directory containing HTML::FormFu's template files is always |
2581
|
|
|
|
|
|
|
added to the end of C<INCLUDE_PATH>, so that the core template files will be |
2582
|
|
|
|
|
|
|
found. You only need to set this yourself if you have your own copy of the |
2583
|
|
|
|
|
|
|
template files for customisation purposes. |
2584
|
|
|
|
|
|
|
|
2585
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
2586
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
2587
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
2588
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
2589
|
|
|
|
|
|
|
defined value. |
2590
|
|
|
|
|
|
|
|
2591
|
|
|
|
|
|
|
=head2 add_tt_args |
2592
|
|
|
|
|
|
|
|
2593
|
|
|
|
|
|
|
Arguments: [\%constructor_arguments] |
2594
|
|
|
|
|
|
|
|
2595
|
|
|
|
|
|
|
Ensures that the hash-ref argument is merged with any existing hash-ref |
2596
|
|
|
|
|
|
|
value of L</tt_args>. |
2597
|
|
|
|
|
|
|
|
2598
|
|
|
|
|
|
|
=head2 tt_module |
2599
|
|
|
|
|
|
|
|
2600
|
|
|
|
|
|
|
Default Value: Template |
2601
|
|
|
|
|
|
|
|
2602
|
|
|
|
|
|
|
The module used when L</render_method> is set to C<tt>. Should provide an |
2603
|
|
|
|
|
|
|
interface compatible with L<Template>. |
2604
|
|
|
|
|
|
|
|
2605
|
|
|
|
|
|
|
This method is a special 'inherited accessor', which means it can be set on |
2606
|
|
|
|
|
|
|
the form, a block element or a single element. When the value is read, if |
2607
|
|
|
|
|
|
|
no value is defined it automatically traverses the element's hierarchy of |
2608
|
|
|
|
|
|
|
parents, through any block elements and up to the form, searching for a |
2609
|
|
|
|
|
|
|
defined value. |
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
=head2 render_data |
2612
|
|
|
|
|
|
|
|
2613
|
|
|
|
|
|
|
Usually called implicitly by L</render>. Returns the data structure that |
2614
|
|
|
|
|
|
|
would normally be passed onto the C<string> or C<tt> render-methods. |
2615
|
|
|
|
|
|
|
|
2616
|
|
|
|
|
|
|
As with L</render>, you must call L</process> once after building the form, |
2617
|
|
|
|
|
|
|
and before calling L</render_data>. |
2618
|
|
|
|
|
|
|
|
2619
|
|
|
|
|
|
|
|
2620
|
|
|
|
|
|
|
=head2 render_data_non_recursive |
2621
|
|
|
|
|
|
|
|
2622
|
|
|
|
|
|
|
Like L</render_data>, but doesn't include the data for any child-elements. |
2623
|
|
|
|
|
|
|
|
2624
|
|
|
|
|
|
|
=head1 INTROSPECTION |
2625
|
|
|
|
|
|
|
|
2626
|
|
|
|
|
|
|
=head2 get_fields |
2627
|
|
|
|
|
|
|
|
2628
|
|
|
|
|
|
|
Arguments: [%options] |
2629
|
|
|
|
|
|
|
|
2630
|
|
|
|
|
|
|
Arguments: [\%options] |
2631
|
|
|
|
|
|
|
|
2632
|
|
|
|
|
|
|
Return Value: \@elements |
2633
|
|
|
|
|
|
|
|
2634
|
|
|
|
|
|
|
Returns all fields in the form (specifically, all elements which have a true |
2635
|
|
|
|
|
|
|
L<HTML::FormFu::Element/is_field> value). |
2636
|
|
|
|
|
|
|
|
2637
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2638
|
|
|
|
|
|
|
|
2639
|
|
|
|
|
|
|
$form->get_fields({ |
2640
|
|
|
|
|
|
|
name => 'foo', |
2641
|
|
|
|
|
|
|
type => 'Radio', |
2642
|
|
|
|
|
|
|
}); |
2643
|
|
|
|
|
|
|
|
2644
|
|
|
|
|
|
|
Accepts also an Regexp to search for results. |
2645
|
|
|
|
|
|
|
|
2646
|
|
|
|
|
|
|
$form->get_elements({ |
2647
|
|
|
|
|
|
|
name => qr/oo/, |
2648
|
|
|
|
|
|
|
}); |
2649
|
|
|
|
|
|
|
|
2650
|
|
|
|
|
|
|
=head2 get_field |
2651
|
|
|
|
|
|
|
|
2652
|
|
|
|
|
|
|
Arguments: [%options] |
2653
|
|
|
|
|
|
|
|
2654
|
|
|
|
|
|
|
Arguments: [\%options] |
2655
|
|
|
|
|
|
|
|
2656
|
|
|
|
|
|
|
Return Value: $element |
2657
|
|
|
|
|
|
|
|
2658
|
|
|
|
|
|
|
Accepts the same arguments as L</get_fields>, but only returns the first |
2659
|
|
|
|
|
|
|
field found. |
2660
|
|
|
|
|
|
|
|
2661
|
|
|
|
|
|
|
=head2 get_elements |
2662
|
|
|
|
|
|
|
|
2663
|
|
|
|
|
|
|
Arguments: [%options] |
2664
|
|
|
|
|
|
|
|
2665
|
|
|
|
|
|
|
Arguments: [\%options] |
2666
|
|
|
|
|
|
|
|
2667
|
|
|
|
|
|
|
Return Value: \@elements |
2668
|
|
|
|
|
|
|
|
2669
|
|
|
|
|
|
|
Returns all top-level elements in the form (not recursive). |
2670
|
|
|
|
|
|
|
See L</get_all_elements> for a recursive version. |
2671
|
|
|
|
|
|
|
|
2672
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2673
|
|
|
|
|
|
|
|
2674
|
|
|
|
|
|
|
$form->get_elements({ |
2675
|
|
|
|
|
|
|
name => 'foo', |
2676
|
|
|
|
|
|
|
type => 'Radio', |
2677
|
|
|
|
|
|
|
}); |
2678
|
|
|
|
|
|
|
|
2679
|
|
|
|
|
|
|
Accepts also an Regexp to search for results. |
2680
|
|
|
|
|
|
|
|
2681
|
|
|
|
|
|
|
$form->get_elements({ |
2682
|
|
|
|
|
|
|
name => qr/oo/, |
2683
|
|
|
|
|
|
|
}); |
2684
|
|
|
|
|
|
|
|
2685
|
|
|
|
|
|
|
=head2 get_element |
2686
|
|
|
|
|
|
|
|
2687
|
|
|
|
|
|
|
Arguments: [%options] |
2688
|
|
|
|
|
|
|
|
2689
|
|
|
|
|
|
|
Arguments: [\%options] |
2690
|
|
|
|
|
|
|
|
2691
|
|
|
|
|
|
|
Return Value: $element |
2692
|
|
|
|
|
|
|
|
2693
|
|
|
|
|
|
|
Accepts the same arguments as L</get_elements>, but only returns the first |
2694
|
|
|
|
|
|
|
element found. |
2695
|
|
|
|
|
|
|
|
2696
|
|
|
|
|
|
|
See L</get_all_element> for a recursive version. |
2697
|
|
|
|
|
|
|
|
2698
|
|
|
|
|
|
|
=head2 get_all_elements |
2699
|
|
|
|
|
|
|
|
2700
|
|
|
|
|
|
|
Arguments: [%options] |
2701
|
|
|
|
|
|
|
|
2702
|
|
|
|
|
|
|
Arguments: [\%options] |
2703
|
|
|
|
|
|
|
|
2704
|
|
|
|
|
|
|
Return Value: \@elements |
2705
|
|
|
|
|
|
|
|
2706
|
|
|
|
|
|
|
Returns all elements in the form recursively. |
2707
|
|
|
|
|
|
|
|
2708
|
|
|
|
|
|
|
Optionally accepts both C<name> and C<type> arguments to narrow the returned |
2709
|
|
|
|
|
|
|
results. |
2710
|
|
|
|
|
|
|
|
2711
|
|
|
|
|
|
|
# return all Text elements |
2712
|
|
|
|
|
|
|
|
2713
|
|
|
|
|
|
|
$form->get_all_elements({ |
2714
|
|
|
|
|
|
|
type => 'Text', |
2715
|
|
|
|
|
|
|
}); |
2716
|
|
|
|
|
|
|
|
2717
|
|
|
|
|
|
|
Accepts also an Regexp to search for results. |
2718
|
|
|
|
|
|
|
|
2719
|
|
|
|
|
|
|
$form->get_elements({ |
2720
|
|
|
|
|
|
|
name => qr/oo/, |
2721
|
|
|
|
|
|
|
}); |
2722
|
|
|
|
|
|
|
|
2723
|
|
|
|
|
|
|
See L</get_elements> for a non-recursive version. |
2724
|
|
|
|
|
|
|
|
2725
|
|
|
|
|
|
|
=head2 get_all_element |
2726
|
|
|
|
|
|
|
|
2727
|
|
|
|
|
|
|
Arguments: [%options] |
2728
|
|
|
|
|
|
|
|
2729
|
|
|
|
|
|
|
Arguments: [\%options] |
2730
|
|
|
|
|
|
|
|
2731
|
|
|
|
|
|
|
Return Value: $element |
2732
|
|
|
|
|
|
|
|
2733
|
|
|
|
|
|
|
Accepts the same arguments as L</get_all_elements>, but only returns the |
2734
|
|
|
|
|
|
|
first element found. |
2735
|
|
|
|
|
|
|
|
2736
|
|
|
|
|
|
|
# return the first Text field found, regardless of whether it's |
2737
|
|
|
|
|
|
|
# within a fieldset or not |
2738
|
|
|
|
|
|
|
|
2739
|
|
|
|
|
|
|
$form->get_all_element({ |
2740
|
|
|
|
|
|
|
type => 'Text', |
2741
|
|
|
|
|
|
|
}); |
2742
|
|
|
|
|
|
|
|
2743
|
|
|
|
|
|
|
Accepts also an Regexp to search for results. |
2744
|
|
|
|
|
|
|
|
2745
|
|
|
|
|
|
|
$form->get_elements({ |
2746
|
|
|
|
|
|
|
name => qr/oo/, |
2747
|
|
|
|
|
|
|
}); |
2748
|
|
|
|
|
|
|
|
2749
|
|
|
|
|
|
|
See L</get_all_elements> for a non-recursive version. |
2750
|
|
|
|
|
|
|
|
2751
|
|
|
|
|
|
|
=head2 get_deflators |
2752
|
|
|
|
|
|
|
|
2753
|
|
|
|
|
|
|
Arguments: [%options] |
2754
|
|
|
|
|
|
|
|
2755
|
|
|
|
|
|
|
Arguments: [\%options] |
2756
|
|
|
|
|
|
|
|
2757
|
|
|
|
|
|
|
Return Value: \@deflators |
2758
|
|
|
|
|
|
|
|
2759
|
|
|
|
|
|
|
Returns all top-level deflators from all fields. |
2760
|
|
|
|
|
|
|
|
2761
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2762
|
|
|
|
|
|
|
|
2763
|
|
|
|
|
|
|
$form->get_deflators({ |
2764
|
|
|
|
|
|
|
name => 'foo', |
2765
|
|
|
|
|
|
|
type => 'Strftime', |
2766
|
|
|
|
|
|
|
}); |
2767
|
|
|
|
|
|
|
|
2768
|
|
|
|
|
|
|
=head2 get_deflator |
2769
|
|
|
|
|
|
|
|
2770
|
|
|
|
|
|
|
Arguments: [%options] |
2771
|
|
|
|
|
|
|
|
2772
|
|
|
|
|
|
|
Arguments: [\%options] |
2773
|
|
|
|
|
|
|
|
2774
|
|
|
|
|
|
|
Return Value: $element |
2775
|
|
|
|
|
|
|
|
2776
|
|
|
|
|
|
|
Accepts the same arguments as L</get_deflators>, but only returns the first |
2777
|
|
|
|
|
|
|
deflator found. |
2778
|
|
|
|
|
|
|
|
2779
|
|
|
|
|
|
|
=head2 get_filters |
2780
|
|
|
|
|
|
|
|
2781
|
|
|
|
|
|
|
Arguments: [%options] |
2782
|
|
|
|
|
|
|
|
2783
|
|
|
|
|
|
|
Arguments: [\%options] |
2784
|
|
|
|
|
|
|
|
2785
|
|
|
|
|
|
|
Return Value: \@filters |
2786
|
|
|
|
|
|
|
|
2787
|
|
|
|
|
|
|
Returns all top-level filters from all fields. |
2788
|
|
|
|
|
|
|
|
2789
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2790
|
|
|
|
|
|
|
|
2791
|
|
|
|
|
|
|
$form->get_filters({ |
2792
|
|
|
|
|
|
|
name => 'foo', |
2793
|
|
|
|
|
|
|
type => 'LowerCase', |
2794
|
|
|
|
|
|
|
}); |
2795
|
|
|
|
|
|
|
|
2796
|
|
|
|
|
|
|
=head2 get_filter |
2797
|
|
|
|
|
|
|
|
2798
|
|
|
|
|
|
|
Arguments: [%options] |
2799
|
|
|
|
|
|
|
|
2800
|
|
|
|
|
|
|
Arguments: [\%options] |
2801
|
|
|
|
|
|
|
|
2802
|
|
|
|
|
|
|
Return Value: $filter |
2803
|
|
|
|
|
|
|
|
2804
|
|
|
|
|
|
|
Accepts the same arguments as L</get_filters>, but only returns the first |
2805
|
|
|
|
|
|
|
filter found. |
2806
|
|
|
|
|
|
|
|
2807
|
|
|
|
|
|
|
=head2 get_constraints |
2808
|
|
|
|
|
|
|
|
2809
|
|
|
|
|
|
|
Arguments: [%options] |
2810
|
|
|
|
|
|
|
|
2811
|
|
|
|
|
|
|
Arguments: [\%options] |
2812
|
|
|
|
|
|
|
|
2813
|
|
|
|
|
|
|
Return Value: \@constraints |
2814
|
|
|
|
|
|
|
|
2815
|
|
|
|
|
|
|
Returns all constraints from all fields. |
2816
|
|
|
|
|
|
|
|
2817
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2818
|
|
|
|
|
|
|
|
2819
|
|
|
|
|
|
|
$form->get_constraints({ |
2820
|
|
|
|
|
|
|
name => 'foo', |
2821
|
|
|
|
|
|
|
type => 'Equal', |
2822
|
|
|
|
|
|
|
}); |
2823
|
|
|
|
|
|
|
|
2824
|
|
|
|
|
|
|
=head2 get_constraint |
2825
|
|
|
|
|
|
|
|
2826
|
|
|
|
|
|
|
Arguments: [%options] |
2827
|
|
|
|
|
|
|
|
2828
|
|
|
|
|
|
|
Arguments: [\%options] |
2829
|
|
|
|
|
|
|
|
2830
|
|
|
|
|
|
|
Return Value: $constraint |
2831
|
|
|
|
|
|
|
|
2832
|
|
|
|
|
|
|
Accepts the same arguments as L</get_constraints>, but only returns the |
2833
|
|
|
|
|
|
|
first constraint found. |
2834
|
|
|
|
|
|
|
|
2835
|
|
|
|
|
|
|
=head2 get_inflators |
2836
|
|
|
|
|
|
|
|
2837
|
|
|
|
|
|
|
Arguments: [%options] |
2838
|
|
|
|
|
|
|
|
2839
|
|
|
|
|
|
|
Arguments: [\%options] |
2840
|
|
|
|
|
|
|
|
2841
|
|
|
|
|
|
|
Return Value: \@inflators |
2842
|
|
|
|
|
|
|
|
2843
|
|
|
|
|
|
|
Returns all inflators from all fields. |
2844
|
|
|
|
|
|
|
|
2845
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2846
|
|
|
|
|
|
|
|
2847
|
|
|
|
|
|
|
$form->get_inflators({ |
2848
|
|
|
|
|
|
|
name => 'foo', |
2849
|
|
|
|
|
|
|
type => 'DateTime', |
2850
|
|
|
|
|
|
|
}); |
2851
|
|
|
|
|
|
|
|
2852
|
|
|
|
|
|
|
=head2 get_inflator |
2853
|
|
|
|
|
|
|
|
2854
|
|
|
|
|
|
|
Arguments: [%options] |
2855
|
|
|
|
|
|
|
|
2856
|
|
|
|
|
|
|
Arguments: [\%options] |
2857
|
|
|
|
|
|
|
|
2858
|
|
|
|
|
|
|
Return Value: $inflator |
2859
|
|
|
|
|
|
|
|
2860
|
|
|
|
|
|
|
Accepts the same arguments as L</get_inflators>, but only returns the |
2861
|
|
|
|
|
|
|
first inflator found. |
2862
|
|
|
|
|
|
|
|
2863
|
|
|
|
|
|
|
=head2 get_validators |
2864
|
|
|
|
|
|
|
|
2865
|
|
|
|
|
|
|
Arguments: [%options] |
2866
|
|
|
|
|
|
|
|
2867
|
|
|
|
|
|
|
Arguments: [\%options] |
2868
|
|
|
|
|
|
|
|
2869
|
|
|
|
|
|
|
Return Value: \@validators |
2870
|
|
|
|
|
|
|
|
2871
|
|
|
|
|
|
|
Returns all validators from all fields. |
2872
|
|
|
|
|
|
|
|
2873
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2874
|
|
|
|
|
|
|
|
2875
|
|
|
|
|
|
|
$form->get_validators({ |
2876
|
|
|
|
|
|
|
name => 'foo', |
2877
|
|
|
|
|
|
|
type => 'Callback', |
2878
|
|
|
|
|
|
|
}); |
2879
|
|
|
|
|
|
|
|
2880
|
|
|
|
|
|
|
=head2 get_validator |
2881
|
|
|
|
|
|
|
|
2882
|
|
|
|
|
|
|
Arguments: [%options] |
2883
|
|
|
|
|
|
|
|
2884
|
|
|
|
|
|
|
Arguments: [\%options] |
2885
|
|
|
|
|
|
|
|
2886
|
|
|
|
|
|
|
Return Value: $validator |
2887
|
|
|
|
|
|
|
|
2888
|
|
|
|
|
|
|
Accepts the same arguments as L</get_validators>, but only returns the |
2889
|
|
|
|
|
|
|
first validator found. |
2890
|
|
|
|
|
|
|
|
2891
|
|
|
|
|
|
|
=head2 get_transformers |
2892
|
|
|
|
|
|
|
|
2893
|
|
|
|
|
|
|
Arguments: [%options] |
2894
|
|
|
|
|
|
|
|
2895
|
|
|
|
|
|
|
Arguments: [\%options] |
2896
|
|
|
|
|
|
|
|
2897
|
|
|
|
|
|
|
Return Value: \@transformers |
2898
|
|
|
|
|
|
|
|
2899
|
|
|
|
|
|
|
Returns all transformers from all fields. |
2900
|
|
|
|
|
|
|
|
2901
|
|
|
|
|
|
|
Accepts both C<name> and C<type> arguments to narrow the returned results. |
2902
|
|
|
|
|
|
|
|
2903
|
|
|
|
|
|
|
$form->get_transformers({ |
2904
|
|
|
|
|
|
|
name => 'foo', |
2905
|
|
|
|
|
|
|
type => 'Callback', |
2906
|
|
|
|
|
|
|
}); |
2907
|
|
|
|
|
|
|
|
2908
|
|
|
|
|
|
|
=head2 get_transformer |
2909
|
|
|
|
|
|
|
|
2910
|
|
|
|
|
|
|
Arguments: [%options] |
2911
|
|
|
|
|
|
|
|
2912
|
|
|
|
|
|
|
Arguments: [\%options] |
2913
|
|
|
|
|
|
|
|
2914
|
|
|
|
|
|
|
Return Value: $transformer |
2915
|
|
|
|
|
|
|
|
2916
|
|
|
|
|
|
|
Accepts the same arguments as L</get_transformers>, but only returns the |
2917
|
|
|
|
|
|
|
first transformer found. |
2918
|
|
|
|
|
|
|
|
2919
|
|
|
|
|
|
|
=head2 clone |
2920
|
|
|
|
|
|
|
|
2921
|
|
|
|
|
|
|
Returns a deep clone of the <$form> object. |
2922
|
|
|
|
|
|
|
|
2923
|
|
|
|
|
|
|
Because of scoping issues, code references (such as in Callback constraints) |
2924
|
|
|
|
|
|
|
are copied instead of cloned. |
2925
|
|
|
|
|
|
|
|
2926
|
|
|
|
|
|
|
=head1 ATTRIBUTE ACCESSORS |
2927
|
|
|
|
|
|
|
|
2928
|
|
|
|
|
|
|
For the basic method, e.g. C</attributes>: |
2929
|
|
|
|
|
|
|
|
2930
|
|
|
|
|
|
|
Arguments: [%attributes] |
2931
|
|
|
|
|
|
|
|
2932
|
|
|
|
|
|
|
Arguments: [\%attributes] |
2933
|
|
|
|
|
|
|
|
2934
|
|
|
|
|
|
|
Return Value: $form |
2935
|
|
|
|
|
|
|
|
2936
|
|
|
|
|
|
|
As a special case, if no arguments are passed, the attributes hash-ref is |
2937
|
|
|
|
|
|
|
returned. This allows the following idioms. |
2938
|
|
|
|
|
|
|
|
2939
|
|
|
|
|
|
|
# set a value |
2940
|
|
|
|
|
|
|
$form->attributes->{id} = 'form'; |
2941
|
|
|
|
|
|
|
|
2942
|
|
|
|
|
|
|
# delete all attributes |
2943
|
|
|
|
|
|
|
%{ $form->attributes } = (); |
2944
|
|
|
|
|
|
|
|
2945
|
|
|
|
|
|
|
All methods documented as 'attribute accessors' also have the following |
2946
|
|
|
|
|
|
|
variants generated: |
2947
|
|
|
|
|
|
|
|
2948
|
|
|
|
|
|
|
C<*_xml> can be used as a setter, and ensures that its argument is not |
2949
|
|
|
|
|
|
|
XML-escaped in the rendered form. |
2950
|
|
|
|
|
|
|
|
2951
|
|
|
|
|
|
|
C<*_loc> can he used as a setter, and passes the arguments through |
2952
|
|
|
|
|
|
|
L</localize>. |
2953
|
|
|
|
|
|
|
|
2954
|
|
|
|
|
|
|
C<add_*> can be used to append a word to an attribute without overwriting |
2955
|
|
|
|
|
|
|
any already-existing value. |
2956
|
|
|
|
|
|
|
|
2957
|
|
|
|
|
|
|
# Example |
2958
|
|
|
|
|
|
|
$form->attributes({ class => 'fancy' }); |
2959
|
|
|
|
|
|
|
$form->add_attributes({ class => 'pants' }); |
2960
|
|
|
|
|
|
|
# class="fancy pants" |
2961
|
|
|
|
|
|
|
|
2962
|
|
|
|
|
|
|
C<add_*_xml>, like C<add_*>, but ensures it doesn't get XML-escaped. |
2963
|
|
|
|
|
|
|
|
2964
|
|
|
|
|
|
|
C<add_*_loc>, like C<add_*>, but passing the arguments through L</localize>. |
2965
|
|
|
|
|
|
|
|
2966
|
|
|
|
|
|
|
C<del_*> can be used to remove a word from an attribute value. |
2967
|
|
|
|
|
|
|
|
2968
|
|
|
|
|
|
|
# Example |
2969
|
|
|
|
|
|
|
$form->attributes({ class => 'fancy pants' }); |
2970
|
|
|
|
|
|
|
$form->del_attributes({ class => 'pants' }); |
2971
|
|
|
|
|
|
|
# class="fancy" |
2972
|
|
|
|
|
|
|
|
2973
|
|
|
|
|
|
|
C<del_*_xml>, like C<del_*>, but ensures it doesn't get XML-escaped. |
2974
|
|
|
|
|
|
|
|
2975
|
|
|
|
|
|
|
C<del_*_loc>, like C<del_*>, but passing the arguments through L</localize>. |
2976
|
|
|
|
|
|
|
|
2977
|
|
|
|
|
|
|
Also, any attribute method-name which contains the word C<attributes> also |
2978
|
|
|
|
|
|
|
has aliases created for all these variants, with the word C<attributes> |
2979
|
|
|
|
|
|
|
replaced by C<attrs>. |
2980
|
|
|
|
|
|
|
|
2981
|
|
|
|
|
|
|
# For example, the attributes() method would have all these variant |
2982
|
|
|
|
|
|
|
# methods available |
2983
|
|
|
|
|
|
|
|
2984
|
|
|
|
|
|
|
$form->attributes({ class => 'fancy' }); |
2985
|
|
|
|
|
|
|
$form->attributes_xml({ title => '<b>fancy</b>' }); |
2986
|
|
|
|
|
|
|
$form->attributes_loc({ title => 'fancy' }); |
2987
|
|
|
|
|
|
|
$form->add_attributes({ class => 'fancy' }); |
2988
|
|
|
|
|
|
|
$form->add_attributes_xml({ title => '<b>fancy</b>' }); |
2989
|
|
|
|
|
|
|
$form->add_attributes_loc({ title => 'fancy' }); |
2990
|
|
|
|
|
|
|
$form->del_attributes({ class => 'fancy' }); |
2991
|
|
|
|
|
|
|
$form->del_attributes_xml({ title => '<b>fancy</b>' }); |
2992
|
|
|
|
|
|
|
$form->del_attributes_loc({ title => 'fancy' }); |
2993
|
|
|
|
|
|
|
|
2994
|
|
|
|
|
|
|
# Because the method contains the word 'attributes', it also gets the |
2995
|
|
|
|
|
|
|
# following short-forms |
2996
|
|
|
|
|
|
|
|
2997
|
|
|
|
|
|
|
$form->attrs({ class => 'fancy' }); |
2998
|
|
|
|
|
|
|
$form->attrs_xml({ title => '<b>fancy</b>' }); |
2999
|
|
|
|
|
|
|
$form->attrs_loc({ title => 'fancy' }); |
3000
|
|
|
|
|
|
|
$form->add_attrs({ class => 'fancy' }); |
3001
|
|
|
|
|
|
|
$form->add_attrs_xml({ title => '<b>fancy</b>' }); |
3002
|
|
|
|
|
|
|
$form->add_attrs_loc({ title => 'fancy' }); |
3003
|
|
|
|
|
|
|
$form->del_attrs({ class => 'fancy' }); |
3004
|
|
|
|
|
|
|
$form->del_attrs_xml({ title => '<b>fancy</b>' }); |
3005
|
|
|
|
|
|
|
$form->del_attrs_loc({ title => 'fancy' }); |
3006
|
|
|
|
|
|
|
|
3007
|
|
|
|
|
|
|
=head1 ATTRIBUTE SHORT-CUTS |
3008
|
|
|
|
|
|
|
|
3009
|
|
|
|
|
|
|
All methods documented as 'attribute short-cuts' are short-cuts to directly |
3010
|
|
|
|
|
|
|
access individual attribute key/values. |
3011
|
|
|
|
|
|
|
|
3012
|
|
|
|
|
|
|
# Example |
3013
|
|
|
|
|
|
|
$form->id( 'login' ); |
3014
|
|
|
|
|
|
|
$id = $form->id; |
3015
|
|
|
|
|
|
|
|
3016
|
|
|
|
|
|
|
# is equivalent to: |
3017
|
|
|
|
|
|
|
$form->attributes({ id => 'login' }); |
3018
|
|
|
|
|
|
|
$id = $form->attributes->{id}; |
3019
|
|
|
|
|
|
|
|
3020
|
|
|
|
|
|
|
All attribute short-cuts also have a C<*_xml> variant. |
3021
|
|
|
|
|
|
|
|
3022
|
|
|
|
|
|
|
# Example |
3023
|
|
|
|
|
|
|
$form->id_xml( $xml ); |
3024
|
|
|
|
|
|
|
|
3025
|
|
|
|
|
|
|
# is equivalent to: |
3026
|
|
|
|
|
|
|
$form->attributes_xml({ id => $xml }); |
3027
|
|
|
|
|
|
|
|
3028
|
|
|
|
|
|
|
All attribute short-cuts also have a C<*_loc> variant. |
3029
|
|
|
|
|
|
|
|
3030
|
|
|
|
|
|
|
# Example |
3031
|
|
|
|
|
|
|
$form->title_loc( $key ); |
3032
|
|
|
|
|
|
|
|
3033
|
|
|
|
|
|
|
# is equivalent to: |
3034
|
|
|
|
|
|
|
$form->attributes_loc({ title => $key }); |
3035
|
|
|
|
|
|
|
|
3036
|
|
|
|
|
|
|
=head1 INHERITING ACCESSORS |
3037
|
|
|
|
|
|
|
|
3038
|
|
|
|
|
|
|
All methods documented as 'inheriting accessors' can be set on the form, |
3039
|
|
|
|
|
|
|
a block element or a single field element. |
3040
|
|
|
|
|
|
|
When the value is read, if no value is defined it automatically traverses |
3041
|
|
|
|
|
|
|
the element's hierarchy of parents, searching for a defined value. |
3042
|
|
|
|
|
|
|
|
3043
|
|
|
|
|
|
|
All inherited accessors also have a C<*_no_inherit> variant, which can be |
3044
|
|
|
|
|
|
|
used as a getter to fetch any defined value, without traversing the |
3045
|
|
|
|
|
|
|
hierarchy of parents. This variant cannot be used as a setter. |
3046
|
|
|
|
|
|
|
|
3047
|
|
|
|
|
|
|
E.g., the L</auto_id> has a variant named C<auto_id_no_inherit>. |
3048
|
|
|
|
|
|
|
|
3049
|
|
|
|
|
|
|
=head1 OUTPUT ACCESSORS |
3050
|
|
|
|
|
|
|
|
3051
|
|
|
|
|
|
|
All methods documented as 'output accessors' also have C<*_xml> and C<*_loc> |
3052
|
|
|
|
|
|
|
variants. |
3053
|
|
|
|
|
|
|
|
3054
|
|
|
|
|
|
|
The C<*_xml> variant can be used as a setter, and ensures that its |
3055
|
|
|
|
|
|
|
argument is not XML-escaped in the rendered form. |
3056
|
|
|
|
|
|
|
|
3057
|
|
|
|
|
|
|
The C<*_loc> variant can be used as a setter, and passes the arguments |
3058
|
|
|
|
|
|
|
through L</localize>. |
3059
|
|
|
|
|
|
|
|
3060
|
|
|
|
|
|
|
E.g., the L<label|HTML::FormFu::Role::Element::Field/label> method has |
3061
|
|
|
|
|
|
|
variants named C<label_xml> and C<label_loc>. |
3062
|
|
|
|
|
|
|
|
3063
|
|
|
|
|
|
|
=head1 BOOLEAN ATTRIBUTE ACCESSORS |
3064
|
|
|
|
|
|
|
|
3065
|
|
|
|
|
|
|
To support boolean attributes, whose value should either be equal to the |
3066
|
|
|
|
|
|
|
attribute name, or empty. Any true value will switch the attribute 'on', any |
3067
|
|
|
|
|
|
|
false value will remove the attribute. |
3068
|
|
|
|
|
|
|
|
3069
|
|
|
|
|
|
|
# Example |
3070
|
|
|
|
|
|
|
|
3071
|
|
|
|
|
|
|
$field->autofocus(1); |
3072
|
|
|
|
|
|
|
# equivalent to: |
3073
|
|
|
|
|
|
|
$field->attributes({ autofocus => 'autofocus' }); |
3074
|
|
|
|
|
|
|
|
3075
|
|
|
|
|
|
|
$field->autofocus(0);; |
3076
|
|
|
|
|
|
|
# equivalent to: |
3077
|
|
|
|
|
|
|
delete $field->attributes->{autofocus}; |
3078
|
|
|
|
|
|
|
|
3079
|
|
|
|
|
|
|
=head1 ATTRIBUTE SUBSTITUTIONS |
3080
|
|
|
|
|
|
|
|
3081
|
|
|
|
|
|
|
Some attributes support character substitutions: the following substitutions |
3082
|
|
|
|
|
|
|
are possible: |
3083
|
|
|
|
|
|
|
|
3084
|
|
|
|
|
|
|
%f # $form->id |
3085
|
|
|
|
|
|
|
%n # $field->name |
3086
|
|
|
|
|
|
|
%t # lc( $field->type ) |
3087
|
|
|
|
|
|
|
%r # $block->repeatable_count |
3088
|
|
|
|
|
|
|
%s # $error->stage |
3089
|
|
|
|
|
|
|
|
3090
|
|
|
|
|
|
|
These allow each field to have consistent attributes, while remaining unique. |
3091
|
|
|
|
|
|
|
|
3092
|
|
|
|
|
|
|
=head1 DEPRECATION POLICY |
3093
|
|
|
|
|
|
|
|
3094
|
|
|
|
|
|
|
We try our best to not make incompatible changes, but if they're required |
3095
|
|
|
|
|
|
|
we'll make every effort possible to provide backwards compatibility for |
3096
|
|
|
|
|
|
|
several release-cycles, issuing a warnings about the changes, before removing |
3097
|
|
|
|
|
|
|
the legacy features. |
3098
|
|
|
|
|
|
|
|
3099
|
|
|
|
|
|
|
=head1 RESTORING LEGACY HTML CLASSES |
3100
|
|
|
|
|
|
|
|
3101
|
|
|
|
|
|
|
C<v1.00> dropped most of the default HTML class-names, with the intention |
3102
|
|
|
|
|
|
|
that each application should define just what it needs, without needing to |
3103
|
|
|
|
|
|
|
reset unwanted options first. We also gain the benefit of less markup being |
3104
|
|
|
|
|
|
|
generated, speeding up both L<render|/render> and HTTP transfers. |
3105
|
|
|
|
|
|
|
|
3106
|
|
|
|
|
|
|
To restore the previous behaviour, set the following options. |
3107
|
|
|
|
|
|
|
|
3108
|
|
|
|
|
|
|
If you're using L<best practices|/"BEST PRACTICES">, you'll only need to set |
3109
|
|
|
|
|
|
|
these once per-application in your app-wide config file. |
3110
|
|
|
|
|
|
|
|
3111
|
|
|
|
|
|
|
--- |
3112
|
|
|
|
|
|
|
auto_container_class: '%t' |
3113
|
|
|
|
|
|
|
auto_container_label_class: 'label' |
3114
|
|
|
|
|
|
|
auto_container_comment_class: 'comment' |
3115
|
|
|
|
|
|
|
auto_comment_class: 'comment' |
3116
|
|
|
|
|
|
|
auto_container_error_class: 'error' |
3117
|
|
|
|
|
|
|
auto_container_per_error_class: 'error_%s_%t' |
3118
|
|
|
|
|
|
|
auto_error_class: 'error_message error_%s_%t' |
3119
|
|
|
|
|
|
|
|
3120
|
|
|
|
|
|
|
=head1 DEPRECATED METHODS |
3121
|
|
|
|
|
|
|
|
3122
|
|
|
|
|
|
|
See L<HTML::FormFu::Role::Element::Field/"DEPRECATED METHODS">. |
3123
|
|
|
|
|
|
|
|
3124
|
|
|
|
|
|
|
=head1 REMOVED METHODS |
3125
|
|
|
|
|
|
|
|
3126
|
|
|
|
|
|
|
See also L<HTML::FormFu::Element/"REMOVED METHODS">. |
3127
|
|
|
|
|
|
|
|
3128
|
|
|
|
|
|
|
=head2 element_defaults |
3129
|
|
|
|
|
|
|
|
3130
|
|
|
|
|
|
|
Has been removed; see L</default_args> instead. |
3131
|
|
|
|
|
|
|
|
3132
|
|
|
|
|
|
|
=head2 model_class |
3133
|
|
|
|
|
|
|
|
3134
|
|
|
|
|
|
|
Has been removed; use L</default_model> instead. |
3135
|
|
|
|
|
|
|
|
3136
|
|
|
|
|
|
|
=head2 defaults_from_model |
3137
|
|
|
|
|
|
|
|
3138
|
|
|
|
|
|
|
Has been removed; use L<HTML::FormFu::Model/default_values> instead. |
3139
|
|
|
|
|
|
|
|
3140
|
|
|
|
|
|
|
=head2 save_to_model |
3141
|
|
|
|
|
|
|
|
3142
|
|
|
|
|
|
|
Has been removed; use L<HTML::FormFu::Model/update> instead. |
3143
|
|
|
|
|
|
|
|
3144
|
|
|
|
|
|
|
=head1 BEST PRACTICES |
3145
|
|
|
|
|
|
|
|
3146
|
|
|
|
|
|
|
It is advisable to keep application-wide (or global) settings in a single |
3147
|
|
|
|
|
|
|
config file, which should be loaded by each form. |
3148
|
|
|
|
|
|
|
|
3149
|
|
|
|
|
|
|
See L</load_config_file>. |
3150
|
|
|
|
|
|
|
|
3151
|
|
|
|
|
|
|
=head1 COOKBOOK |
3152
|
|
|
|
|
|
|
|
3153
|
|
|
|
|
|
|
L<HTML::FormFu::Manual::Cookbook> |
3154
|
|
|
|
|
|
|
|
3155
|
|
|
|
|
|
|
=head2 UNICODE |
3156
|
|
|
|
|
|
|
|
3157
|
|
|
|
|
|
|
L<HTML::FormFu::Manual::Unicode> |
3158
|
|
|
|
|
|
|
|
3159
|
|
|
|
|
|
|
=head1 EXAMPLES |
3160
|
|
|
|
|
|
|
|
3161
|
|
|
|
|
|
|
=head2 vertically-aligned CSS |
3162
|
|
|
|
|
|
|
|
3163
|
|
|
|
|
|
|
The distribution directory C<examples/vertically-aligned> contains a form with |
3164
|
|
|
|
|
|
|
example CSS for a "vertically aligned" theme. |
3165
|
|
|
|
|
|
|
|
3166
|
|
|
|
|
|
|
This can be viewed by opening the file C<vertically-aligned.html> in a |
3167
|
|
|
|
|
|
|
web-browser. |
3168
|
|
|
|
|
|
|
|
3169
|
|
|
|
|
|
|
If you wish to experiment with making changes, the form is defined in file |
3170
|
|
|
|
|
|
|
C<vertically-aligned.yml>, and the HTML file can be updated with any changes |
3171
|
|
|
|
|
|
|
by running the following command (while in the distribution root directory). |
3172
|
|
|
|
|
|
|
|
3173
|
|
|
|
|
|
|
perl examples/vertically-aligned/vertically-aligned.pl |
3174
|
|
|
|
|
|
|
|
3175
|
|
|
|
|
|
|
This uses the L<Template Toolkit|Template> file C<vertically-aligned.tt>, |
3176
|
|
|
|
|
|
|
and the CSS is defined in files C<vertically-aligned.css> and |
3177
|
|
|
|
|
|
|
C<vertically-aligned-ie.css>. |
3178
|
|
|
|
|
|
|
|
3179
|
|
|
|
|
|
|
=head1 SUPPORT |
3180
|
|
|
|
|
|
|
|
3181
|
|
|
|
|
|
|
Project Page: |
3182
|
|
|
|
|
|
|
|
3183
|
|
|
|
|
|
|
L<http://code.google.com/p/html-formfu/> |
3184
|
|
|
|
|
|
|
|
3185
|
|
|
|
|
|
|
Mailing list: |
3186
|
|
|
|
|
|
|
|
3187
|
|
|
|
|
|
|
L<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu> |
3188
|
|
|
|
|
|
|
|
3189
|
|
|
|
|
|
|
Mailing list archives: |
3190
|
|
|
|
|
|
|
|
3191
|
|
|
|
|
|
|
L<http://lists.scsys.co.uk/pipermail/html-formfu/> |
3192
|
|
|
|
|
|
|
|
3193
|
|
|
|
|
|
|
IRC: |
3194
|
|
|
|
|
|
|
|
3195
|
|
|
|
|
|
|
C<irc.perl.org>, channel C<#formfu> |
3196
|
|
|
|
|
|
|
|
3197
|
|
|
|
|
|
|
The HTML::Widget archives L<http://lists.scsys.co.uk/pipermail/html-widget/> |
3198
|
|
|
|
|
|
|
between January and May 2007 also contain discussion regarding HTML::FormFu. |
3199
|
|
|
|
|
|
|
|
3200
|
|
|
|
|
|
|
=head1 BUGS |
3201
|
|
|
|
|
|
|
|
3202
|
|
|
|
|
|
|
Please submit bugs / feature requests to |
3203
|
|
|
|
|
|
|
L<http://code.google.com/p/html-formfu/issues/list> (preferred) or |
3204
|
|
|
|
|
|
|
L<http://rt.perl.org>. |
3205
|
|
|
|
|
|
|
|
3206
|
|
|
|
|
|
|
=head1 PATCHES |
3207
|
|
|
|
|
|
|
|
3208
|
|
|
|
|
|
|
To help patches be applied quickly, please send them to the mailing list; |
3209
|
|
|
|
|
|
|
attached, rather than inline; against subversion, rather than a cpan version |
3210
|
|
|
|
|
|
|
(run C<< svn diff > patchfile >>); mention which svn version it's against. |
3211
|
|
|
|
|
|
|
Mailing list messages are limited to 256KB, so gzip the patch if necessary. |
3212
|
|
|
|
|
|
|
|
3213
|
|
|
|
|
|
|
=head1 GITHUB REPOSITORY |
3214
|
|
|
|
|
|
|
|
3215
|
|
|
|
|
|
|
This module's sourcecode is maintained in a git repository at |
3216
|
|
|
|
|
|
|
L<git://github.com/fireartist/HTML-FormFu.git> |
3217
|
|
|
|
|
|
|
|
3218
|
|
|
|
|
|
|
The project page is L<https://github.com/fireartist/HTML-FormFu> |
3219
|
|
|
|
|
|
|
|
3220
|
|
|
|
|
|
|
=head1 SEE ALSO |
3221
|
|
|
|
|
|
|
|
3222
|
|
|
|
|
|
|
L<HTML::FormFu::Imager> |
3223
|
|
|
|
|
|
|
|
3224
|
|
|
|
|
|
|
L<Catalyst::Controller::HTML::FormFu> |
3225
|
|
|
|
|
|
|
|
3226
|
|
|
|
|
|
|
L<HTML::FormFu::Model::DBIC> |
3227
|
|
|
|
|
|
|
|
3228
|
|
|
|
|
|
|
=head1 AUTHORS |
3229
|
|
|
|
|
|
|
|
3230
|
|
|
|
|
|
|
Carl Franks |
3231
|
|
|
|
|
|
|
|
3232
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
3233
|
|
|
|
|
|
|
|
3234
|
|
|
|
|
|
|
Brian Cassidy |
3235
|
|
|
|
|
|
|
|
3236
|
|
|
|
|
|
|
Ozum Eldogan |
3237
|
|
|
|
|
|
|
|
3238
|
|
|
|
|
|
|
Ruben Fonseca |
3239
|
|
|
|
|
|
|
|
3240
|
|
|
|
|
|
|
Ronald Kimball |
3241
|
|
|
|
|
|
|
|
3242
|
|
|
|
|
|
|
Daisuke Maki |
3243
|
|
|
|
|
|
|
|
3244
|
|
|
|
|
|
|
Andreas Marienborg |
3245
|
|
|
|
|
|
|
|
3246
|
|
|
|
|
|
|
Mario Minati |
3247
|
|
|
|
|
|
|
|
3248
|
|
|
|
|
|
|
Steve Nolte |
3249
|
|
|
|
|
|
|
|
3250
|
|
|
|
|
|
|
Moritz Onken |
3251
|
|
|
|
|
|
|
|
3252
|
|
|
|
|
|
|
Doug Orleans |
3253
|
|
|
|
|
|
|
|
3254
|
|
|
|
|
|
|
Matthias Dietrich |
3255
|
|
|
|
|
|
|
|
3256
|
|
|
|
|
|
|
Dean Hamstead |
3257
|
|
|
|
|
|
|
|
3258
|
|
|
|
|
|
|
Karen Etheridge |
3259
|
|
|
|
|
|
|
|
3260
|
|
|
|
|
|
|
Nigel Metheringham |
3261
|
|
|
|
|
|
|
|
3262
|
|
|
|
|
|
|
Based on the original source code of L<HTML::Widget>, by Sebastian Riedel, |
3263
|
|
|
|
|
|
|
C<sri@oook.de>. |
3264
|
|
|
|
|
|
|
|
3265
|
|
|
|
|
|
|
=head1 LICENSE |
3266
|
|
|
|
|
|
|
|
3267
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
3268
|
|
|
|
|
|
|
the same terms as Perl itself. |
3269
|
|
|
|
|
|
|
|
3270
|
|
|
|
|
|
|
=head1 PERL GAME |
3271
|
|
|
|
|
|
|
|
3272
|
|
|
|
|
|
|
Play the MMO written in perl: L<http://www.lacunaexpanse.com>! |
3273
|
|
|
|
|
|
|
|
3274
|
|
|
|
|
|
|
=cut |