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 /],
});

# bar is not supplied as part of query
$form->process({
 foo => 'a'
});

print Dumper( $form->params );

# output:

# $VAR1 = {
#    'foo' => 'a'
# };


# desired output:

# $VAR1 = {
#    'foo' => 'a',
#    'bar' => 'b'
# };
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to