More.pm

filter: Statementstmt 88.5% 124 / 140 Branchbran 64.1% 50 / 78 Conditioncond 45.0% 18 / 40 MC/DCmcdc 20.0% 5 / 25 Subroutinesub 90.9% 20 / 22 Podpod 100% 13 / 13 totaltotal 72.3% 230 / 318 CC 58 SCAR 21.1
CC
58
Cov
74%
pressed
14.1
input
13.6
input_slice
11.2
CRAP 8.2
↑ Summary More/InputTie.pm »
1 package CGI::FormBuilderX::More;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 CGI::FormBuilderX::More - Additional input gathering/interrogating functionality for CGI::FormBuilder
9  
10 =head1 VERSION
11  
12 Version 0.020
13  
14 =cut
15  
16 3 our $VERSION = '0.020';
17  
18 =head1 SYNOPSIS
19  
20 use CGI::FormBuilderX::More;
21  
22 my $form = CGI::FormBuilderX::More( ... );
23  
24 if ($form->pressed("edit")) {
25 my $input = $form->input_slice(qw/title description/);
26 # $input is { title => ..., description => ... } *ONLY*
27 ...
28 }
29 elsif ($form->pressed("view") && ! $form->missing("section")) {
30 # The paramter "section" is defined and is not ''
31 ...
32 }
33  
34 print $form->render;
35  
36 ...
37  
38 # Using the alternative, subroutine-driven, validation
39  
40 my $form = CGI::FormBuilderX::More( ..., validate => sub {
41 my ($form, $error) = @_;
42  
43 if (! exists $_{username}) {
44 $error->("username is required"); # Register the error
45 }
46 elsif ($_{username} =~ m/\W/) {
47 $error->("username is malformed"); # A username was given but it's bad
48 }
49  
50 if (! exists $_{password}) {
51 $error->("password is required"); # Another error...
52 }
53  
54 return if $error->(); # See if we've accumulated any errors
55  
56 unless (&authenticate({ $form->input_slice(qw/username password/) })) {
57 $error->("no such username or incorrect password");
58 }
59 });
60  
61 if ($form->validate) {
62  
63 }
64 else {
65  
66 }
67  
68 =head1 DESCRIPTION
69  
70 CGI::FormBuilderX::More extends CGI::FormBuilder by adding some convenience methods. Specifically,
71 it adds methods for generating param lists, generating param hash slices, determining whether a param is "missing",
72 and finding out which submit button was pressed.
73  
74 =head1 EXPORT
75  
76 =head2 missing( <value> )
77  
78 Returns 1 if <value> is not defined or the empty string ('')
79 Returns 0 otherwise
80  
81 Note, the number 0 is NOT a "missing" value
82  
83 =cut
84  
85 3 ▶use base qw/CGI::FormBuilder/;
Subroutine BEGIN: called CC=1 SCAR=0.0
86  
87 3 ▶use CGI::FormBuilderX::More::InputTie;
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 3 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=2.2
90 exports => [
91 0 ▶ missing => sub { return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=2 SCAR=17.9
92 0 ▶ return ! defined $_[0] || $_[0] eq '';
Condition0%0/3
!defined($_[0]) || $_[0] eq ''
l!l&&r!l&&!r
000
MC/DC0%0/2
!defined($_[0]) || $_[0] eq ''
!defined($_[0]) $_[0] eq ''
Truth table0%0/3
not(A) || B
A= !defined($_[0])B= $_[0] eq ''
ABresult
1X1
011
000
93 0 } },
94 3 ],
95 3 };
96  
97 49 ▶sub _attribute($) {
Subroutine _attribute: called CC=1 SCAR=0.0
98 49 return "_CGI_FBX_M_$_[0]";
99 }
100  
101 =head1 METHODS
102  
103 =head2 CGI::FormBuilderX::More->new( ... )
104  
105 Returns a new CGI::FormBuilderX::More object
106  
107 Configure exactly as you would a normal CGI::FormBuilder object
108  
109 =cut
110  
111 3 ▶sub new {
Subroutine new: called CC=7 SCAR=21.0
Pod documented
112 3 my $class = shift;
113  
114 3 my $hash;
115 3 ▶ if (@_ == 1 && ref $_[0] eq "HASH") {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 0 3 3
elsif (@_ > 1) { } 3 0 3
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
300
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
116 0 $hash = $_[0];
117 }
118 elsif (@_ > 1) {
119 3 $hash = { @_ };
120 }
121  
122 3 my $self;
123 3 ▶ if ($hash) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash) { } 3 0 3
124 3 my $validate;
125 3 ▶ if ($hash->{validate} && ref $hash->{validate} eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash->{"validate"} and ref $hash->{"validate"} eq "CODE") 1 2 3
Condition66%2/3
$hash->{"validate"} and ref $hash->{"validate"} eq "CODE"
!ll&&!rl&&r
201
MC/DC50%1/2
$hash->{"validate"} and ref $hash->{"validate"} eq "CODE"
$hash->{"validate"} ref $hash->{"validate"} eq "CODE"
Truth table66%2/3
A and B
A= $hash->{"validate"}B= ref $hash->{"validate"} eq "CODE"
ABresult
0X0
100
111
126 1 $validate = delete $hash->{validate};
127 }
128 3 $self = $class->SUPER::new($hash);
129 3 $self->{_attribute("validate")} = $validate;
130 }
131 else {
132 0 $self = $class->SUPER::new(@_);
133 }
134
135 3 return $self;
136 }
137  
138 =head2 pressed( <name> )
139  
140 Returns the value of ->param(_submit_<name>) if _submit_<name> exists and has a value
141  
142 If not, then returns the value of ->param("_submit_<name>.x") if "_submit_<name>.x" exists and has a value
143  
144 If <name> is not given, then it will use the form's default submit name to check.
145  
146 To suppress the automatic prefixing of <name> with "_submit", simply prefix a "+" to <name>
147  
148 If <name> already has a "_submit" prefix, then none will be applied.
149  
150 Otherwise, returns undef
151  
152 Essentially, you can use this method to find out which button the user pressed. This method does not require
153 any javascript on the client side to work
154  
155 It checks "_submit_<name>.x" because for image buttons, some browsers only submit the .x and .y values of where the user
156 pressed.
157  
158 =cut
159  
160 3 ▶sub pressed {
Subroutine pressed: called CC=10 SCAR=26.4
Pod documented
161 3 my $self = shift;
162  
163 3 my ($name, $default);
164 3 ▶ if (! @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @_) { } 0 3 3
165 0 $name = $self->submitname;
166 0 $default = 1;
167 }
168 else {
169 3 $name = shift;
170 3 ▶ if (defined $name && length $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name and length $name) { } 3 0 3
Condition33%1/3
defined $name and length $name
!ll&&!rl&&r
003
MC/DC0%0/2
defined $name and length $name
defined $name length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
171 3 ▶ $name = "_submit_$name" unless $name =~ m/^_submit/i || $name =~ s/^\+//;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^_submit/i or $name =~ s/^\+// 0 3 3
Condition33%1/3
$name =~ /^_submit/i or $name =~ s/^\+//
l!l&&r!l&&!r
030
MC/DC0%0/2
$name =~ /^_submit/i or $name =~ s/^\+//
$name =~ /^_submit/i $name =~ s/^\+//
Truth table33%1/3
A or B
A= $name =~ /^_submit/iB= $name =~ s/^\+//
ABresult
1X1
011
000
172 }
173 else {
174 0 $name = $self->submitname;
175 }
176 }
177  
178 3 for ($name, "$name.x") {
179 5 ▶ if (defined (my $value = $self->input_fetch($_))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $self->input_fetch($_))) 2 3 5
180 2 ▶ return $value || '0E0';
Condition100%2/2
$value || '0E0'
l!l
11
MC/DC100%1/1
$value || '0E0'
$value
Truth table100%2/2
A
A= $value
Aresult
11
00
181 }
182 }
183  
184 1 ▶ return $self->submitted if $default;
Branch: 1 branch
BranchTrueFalseTotal
if $default 0 1 1
185  
186 1 return undef;
187 }
188  
189 =head2 missing( <name> )
190  
191 Returns 1 if value of the param <name> is not defined or the empty string ('')
192 Returns 0 otherwise
193  
194 Note, the number 0 is NOT a "missing" value
195  
196 value missing
197 ===== =======
198 "xyzzy" no
199 0 no
200 1 no
201 "" yes
202 undef yes
203  
204 =cut
205  
206 9 ▶sub missing {
Subroutine missing: called CC=4 SCAR=15.9
Pod documented
207 9 my $self = shift;
208 9 my $name = shift;
209 9 my $value = $self->input_fetch($name);
210  
211 9 ▶ return 0 if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 4 5 9
212 5 ▶ return 1 if ! defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 5 0 5
213 0 ▶ return 1 if $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 0 0 0
214 0 return 0; # value is 0
215 }
216  
217 =head2 input ( <name>, <name>, ..., <name> )
218  
219 Returns a list of values based on the param names given
220  
221 By default, this method will "collapse" multi-value params into the first
222 value of the param. If you'd prefer an array reference of multi-value params
223 instead, pass the option { all => 1 } as the first argument (a hash reference).
224  
225 =cut
226  
227 3 ▶sub input {
Subroutine input: called CC=13 SCAR=26.1
Pod documented
228 3 my $self = shift;
229 3 ▶ return $self->input_fetch(@_) if wantarray && 1 == @_ && ! ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if wantarray and 1 == @_ and not ref $_[0] 0 3 3
Condition50%3/6
wantarray and 1 == @_ and not ref $_[0]
!ll&&!rl&&r
300
wantarray and 1 == @_
!ll&&!rl&&r
120
MC/DC0%0/3
wantarray and 1 == @_ and not ref $_[0]
wantarray 1 == @_ not ref $_[0]
Truth table50%2/4
A and B and not(C)
A= wantarrayB= 1 == @_C= not ref $_[0]
ABCresult
0XX0
10X0
1100
1111
230  
231 3 my $control = {};
232 3 ▶ $control = shift if ref $_[0] && ref $_[0] eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] and ref $_[0] eq "HASH" 1 2 3
Condition66%2/3
ref $_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
201
MC/DC50%1/2
ref $_[0] and ref $_[0] eq "HASH"
ref $_[0] ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
233 3 my $all = 0;
234 3 ▶ $all = $control->{all} if exists $control->{all};
Branch: 1 branch
BranchTrueFalseTotal
if exists $control->{"all"} 1 2 3
235  
236 3 ▶ my @names = map { ref eq 'ARRAY' ? @$_ : $_ } @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 5 5
237  
238 3 my @params;
239 3 ▶ if ($all) {
Branch: 1 branch
BranchTrueFalseTotal
if ($all) { } 1 2 3
240 1 for (@names) {
241 2 my @param = $self->input_fetch($_);
242 2 ▶ push @params, 1 == @param ? $param[0] : \@param;
Branch: 1 branch
BranchTrueFalseTotal
1 == @param ? : 1 1 2
243 }
244 }
245 else {
246 2 for (@names) {
247 3 push @params, scalar $self->input_fetch($_);
248 }
249 }
250 3 ▶ return wantarray ? @params : $params[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 1 3
251 }
252  
253 =head2 input_slice( <name>, <name>, ..., <name> )
254  
255 Returns a hash of key/value pairs based on the param names given
256  
257 By default, this method will "collapse" multi-value params into the first
258 value of the param. If you'd prefer an array reference of multi-value params
259 instead, pass the option { all => 1 } as the first argument (a hash reference).
260  
261 =cut
262  
263 2 ▶sub input_slice {
Subroutine input_slice: called CC=8 SCAR=24.1
Pod documented
264 2 my $self = shift;
265 2 my $control = {};
266 2 ▶ $control = shift if ref $_[0] && ref $_[0] eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] and ref $_[0] eq "HASH" 0 2 2
Condition33%1/3
ref $_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
200
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "HASH"
ref $_[0] ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= ref $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
267 2 my $all = 0;
268 2 ▶ $all = $control->{all} if exists $control->{all};
Branch: 1 branch
BranchTrueFalseTotal
if exists $control->{"all"} 0 2 2
269  
270 2 ▶ my @names = map { ref eq 'ARRAY' ? @$_ : $_ } @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 4 4
271  
272 2 my %slice;
273 2 ▶ if ($all) {
Branch: 1 branch
BranchTrueFalseTotal
if ($all) { } 0 2 2
274 0 ▶ %slice = map { my @param = $self->input_fetch($_); ($_ => 1 == @param ? $param[0] : \@param) } @names;
Branch: 1 branch
BranchTrueFalseTotal
1 == @param ? : 0 0 0
275 }
276 else {
277 2 %slice = map { ($_ => scalar $self->input_fetch($_)) } @names;
278 }
279  
280 2 ▶ return wantarray ? %slice : \%slice;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
281 }
282  
283 =head2 input_slice_to( <hash>, <name>, <name>, ..., <name> )
284  
285 The behavior of this method is similar to C<input_slice>, except instead of returning a new hash, it will modify
286 the hash passed in as the first argument.
287  
288 Returns the original hash passed in
289  
290 =cut
291  
292 1 ▶sub input_slice_to {
Subroutine input_slice_to: called CC=2 SCAR=6.9
Pod documented
293 1 my $self = shift;
294 1 my $hash = shift;
295 1 my $slice = { $self->input_slice(@_) };
296 1 $hash->{$_} = $slice->{$_} for keys %$slice;
297 1 return $hash;
298 }
299  
300 =head2 input_param( <name> )
301  
302 In list context, returns the all the param values associated with <name>
303 In scalar context, returns only the first param value associated with <name>
304  
305 The main difference between C<input_param> and C<input> is that C<input_param> only accepts a single argument
306 AND C<input_param> addresses the param object directly, while C<input> will access the internal C<input_fetch>/C<input_store> hash
307  
308 =cut
309  
310 34 ▶sub input_param {
Subroutine input_param: called CC=2 SCAR=6.9
Pod documented
311 34 my $self = shift;
312 34 my @param = $self->{params}->param($_[0]);
313 34 ▶ return wantarray ? @param : shift @param;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 7 27 34
314 }
315  
316 =head2 validate( [<code>] )
317  
318 In CGI::FormBuilderX::More, we overload to the validate method to offer different behavior. This different
319 behavior is conditional, and depends on the optional first argument, or the value of C<validate> passed in to C<new>.
320  
321 If either the first argument or ->new( validate => ... ) is a code reference then $form->validate takes on different behavior:
322  
323 1. %_ is tied() to the form's input parameters
324 2. An error subroutine for recoding errors is passed through as the first argument to the validation subroutine
325 3. Any additional arguments to validate are passed through to the validation subroutine
326 4. The errors are available via $form->errors, which is a list reference
327 5. The errors are also available in the prepared version of $form (e.g. for template rendering)
328 6. $form->validate returns true or false depending on whether any errors were encountered
329  
330 Here is an example validation subroutine:
331  
332 sub {
333 my ($form, $error) = @_;
334  
335 if (! exists $_{username}) {
336 $error->("username is required"); # Register the error
337 }
338 elsif ($_{username} =~ m/\W/) {
339 $error->("username is malformed"); # A username was given but it's bad
340 }
341  
342 if (! exists $_{password}) {
343 $error->("password is required"); # Another error...
344 }
345  
346 return if $error->(); # See if we've accumulated any errors
347  
348 unless (&authenticate({ $form->input_slice(qw/username password/) })) {
349 $error->("no such username or incorrect password");
350 }
351 }
352  
353 =cut
354  
355 3 ▶sub validate {
Subroutine validate: called CC=6 SCAR=19.3
Pod documented
356 3 my $self = shift;
357 3 my $code;
358 3 ▶ if ($_[0] && ref $_[0] eq "CODE") {
Branch: 2 branches
BranchTrueFalseTotal
if ($_[0] and ref $_[0] eq 'CODE') { } 3 0 3
elsif ($code = $$self{&_attribute('validate')}) { } 0 0 0
Condition33%1/3
$_[0] and ref $_[0] eq "CODE"
!ll&&!rl&&r
003
MC/DC0%0/2
$_[0] and ref $_[0] eq "CODE"
$_[0] ref $_[0] eq "CODE"
Truth table33%1/3
A and B
A= $_[0]B= ref $_[0] eq "CODE"
ABresult
0X0
100
111
359 3 $code = shift;
360 }
361 elsif ($code = $self->{_attribute("validate")}) {
362 }
363 else {
364 0 return $self->SUPER::validate(@_);
365 }
366 3 local %_;
367 3 $self->input_tie(\%_);
368 3 my @errors;
369 2 ▶ my $error = sub {
Subroutine __ANON__: called CC=3 SCAR=14.2
370 2 ▶ return @errors ? 1 : 0 unless @_;
Branch: 2 branches
BranchTrueFalseTotal
unless @_ 0 2 2
@errors ? : 0 0 0
371 2 push @errors, @_;
372 3 };
373 3 eval {
374 3 $code->($self, $error, @_);
375 };
376 {
377 3 my $error = $@;
378 3 untie %_;
379 3 ▶ die $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 3 3
380 }
381 3 $self->{_attribute("errors")} = \@errors;
382 3 ▶ return scalar @errors ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
scalar @errors ? : 2 1 3
383 }
384  
385 =head2 input_tie( <hash> )
386  
387 Given a hash reference, C<input_tie> will tie the hash to form input. That is,
388 accessing a hash entry is actually accessing the corresponding form param.
389 Currently, only STORE, FETCH, and EXISTS are implemented.
390  
391 my %hash;
392 $form->input_tie(\%hash);
393  
394 my $value = $hash{username}; # Actually does: $form->input_fetch("username");
395  
396 $hash{password} = "12345"; # Actually does: $form->input_store(password => "12345");
397  
398 return unless exists $hash{extra}; # Actually does: ! $form->missing("extra");
399 # Which checks to see if "extra" is defined and a non-empty string.
400  
401 =cut
402  
403 3 ▶sub input_tie {
Subroutine input_tie: called CC=1 SCAR=0.0
Pod documented
404 3 my $self = shift;
405 3 my $hash = shift;
406 3 tie %$hash, "CGI::FormBuilderX::More::InputTie", $self;
407 3 return $hash;
408 }
409  
410 =head2 input_fetch( <key> )
411  
412 Given a key, C<input_fetch> will return the value of first
413 an internal attribute stash, and then request paramters (via C<input_param>).
414  
415 This allows you get/set values in the form without affecting the underlying request param.
416  
417 In array context, the entire value list is returned. In scalar context, only the first value is returned.
418  
419 =cut
420  
421 31 ▶sub input_fetch {
Subroutine input_fetch: called CC=3 SCAR=11.0
Pod documented
422 31 my $self = shift;
423 31 my $key = shift;
424 31 ▶ if (exists $self->{_attribute("input")}->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$self{&_attribute('input')}{$key}) { } 3 28 31
425 3 my @param = @{ $self->{_attribute("input")}->{$key} };
426 3 ▶ return wantarray ? @param : shift @param;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 2 3
427 }
428 else {
429 28 return $self->input_param($key);
430 }
431 }
432  
433 =head2 input_store( <key>, <value>, <value>, ..., <value> )
434  
435 Given a key and some values, C<input_store> will store the values (as an array reference)
436 in an internal attribute stash.
437  
438 This allows you get/set values in the form without affecting the underlying request param.
439  
440 =cut
441  
442 3 ▶sub input_store {
Subroutine input_store: called CC=3 SCAR=11.0
Pod documented
443 3 my $self = shift;
444 3 my $key = shift;
445 3 ▶ my @values = 1 == @_ && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
1 == @_ && ref $_[0] eq 'ARRAY' ? : 1 2 3
Condition66%2/3
1 == @_ and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
021
MC/DC50%1/2
1 == @_ and ref $_[0] eq "ARRAY"
1 == @_ ref $_[0] eq "ARRAY"
Truth table66%2/3
A and B
A= 1 == @_B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
446 3 $self->{_attribute("input")}->{$key} = \@values;
447 }
448  
449 =head2 errors
450  
451 In scalar context, returns an array reference of errors found during validation, if any.
452 In list context, returns the same, but as a list.
453  
454 =cut
455  
456 6 ▶sub errors {
Subroutine errors: called CC=6 SCAR=23.5
Pod documented
457 6 my $self = shift;
458 6 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 6 6
459 0 ▶ my @errors = 1 == @_ && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
1 == @_ && ref $_[0] eq 'ARRAY' ? : 0 0 0
Condition0%0/3
1 == @_ and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
1 == @_ and ref $_[0] eq "ARRAY"
1 == @_ ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= 1 == @_B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
460 0 $self->{_attribute("errors")} = \@errors;
461 }
462  
463 6 ▶ my $errors = $self->{_attribute("errors")} || [];
Condition100%2/2
$$self{&_attribute('errors')} || []
l!l
33
MC/DC100%1/1
$$self{&_attribute('errors')} || []
$$self{&_attribute('errors')}
Truth table100%2/2
A
A= $$self{&_attribute('errors')}
Aresult
11
00
464 6 ▶ return wantarray ? @$errors : [ @$errors ];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 5 6
465 }
466  
467 =head2 prepare
468  
469 Prepares a hash containing information about the state of the form and returns it.
470  
471 Essentially, returns the same as CGI::FormBuilder->prepare, with the addition of C<errors>, which is
472 a list of any errors found during validation.
473  
474 Returns a hash reference in scalar context, and a key/value list in array context.
475  
476 =cut
477  
478 3 ▶sub prepare {
Subroutine prepare: called CC=2 SCAR=6.9
Pod documented
479 3 my $self = shift;
480 3 my $prepare = $self->SUPER::prepare(@_);
481 3 $prepare->{errors} = $self->errors;
482 3 ▶ return wantarray ? %$prepare : $prepare;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 2 3
483 }
484  
485 =head1 AUTHOR
486  
487 Robert Krimen, C<< <rkrimen at cpan.org> >>
488  
489 =head1 BUGS
490  
491 Please report any bugs or feature requests to C<bug-cgi-formbuilderx-more at rt.cpan.org>, or through
492 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-FormBuilderX-More>. I will be notified, and then you'll
493 automatically be notified of progress on your bug as I make changes.
494  
495  
496  
497  
498 =head1 SUPPORT
499  
500 You can find documentation for this module with the perldoc command.
501  
502 perldoc CGI::FormBuilderX::More
503  
504  
505 You can also look for information at:
506  
507 =over 4
508  
509 =item * RT: CPAN's request tracker
510  
511 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CGI-FormBuilderX-More>
512  
513 =item * AnnoCPAN: Annotated CPAN documentation
514  
515 L<http://annocpan.org/dist/CGI-FormBuilderX-More>
516  
517 =item * CPAN Ratings
518  
519 L<http://cpanratings.perl.org/d/CGI-FormBuilderX-More>
520  
521 =item * Search CPAN
522  
523 L<http://search.cpan.org/dist/CGI-FormBuilderX-More>
524  
525 =back
526  
527  
528 =head1 ACKNOWLEDGEMENTS
529  
530  
531 =head1 COPYRIGHT & LICENSE
532  
533 Copyright 2007 Robert Krimen, all rights reserved.
534  
535 This program is free software; you can redistribute it and/or modify it
536 under the same terms as Perl itself.
537  
538  
539 =cut
540  
541 3 1; # End of CGI::FormBuilderX::More
↑ Summary More/InputTie.pm »