[html-formfu] Taking default value when not supplied in query
(plaintext)
Wicked bits
wickedbits at gmail.com
Sat Oct 9 16:16:09 GMT 2010
Sorry for the mangled post, here it is plainly:
When FormFu processes a query that contains only some of the defined
fields, how can the fields that don't appear in the query have their
default value(s) in $form->params?
#!/usr/bin/perl
use strict;
use HTML::FormFu;
use Data::Dumper;
my $form = HTML::FormFu->new;
$form->indicator('foo'); # only foo is required to be considered submitted
# required field
$form->element({
name => 'foo',
constraints => 'Required'
});
# optional field - when bar is not supplied, should use its default
$form->element({
name => 'bar',
type => 'Select',
default => 'b',
retain_default => 1,
values => [qw/ a b c /],
constraints => 'AutoSet'
});
# bar is not supplied as part of query
$form->process({
foo => 'a'
});
print Dumper( $form->params );
# output:
# $VAR1 = {
# 'foo' => 'a'
# };
# expected output:
# $VAR1 = {
# 'foo' => 'a',
# 'bar' => 'b'
# };
More information about the HTML-FormFu
mailing list