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'
# };

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to