[html-formfu] form still valid after force_error()
Steve Caldwell
info-formfu at caldwellhb.com
Sun Mar 9 20:29:33 GMT 2008
In the script below, I'm forcing an error on an otherwise successfully
submitted form, using force_errors(), as laid out in the Cookbook.
However, after doing so, the form is still returning true when calling
submitted_and_valid(). Shouldn't force_errors() result in has_errors()
returning true (and thus submitted_and_valid() returning false)?
#!/usr/bin/perl
use HTML::FormFu;
use YAML;
my $form = new HTML::FormFu;
$form->populate(YAML::Load(<<"EOM"));
elements:
- type: Text
name: bar
constraints:
- type: Required
message: Missing
- type: Checkbox
name: foo
value: 1
constraints:
- type: Callback
message: You can't do that
- type: Hidden
name: submitted
value: 1
indicator: submitted
EOM
$form->process({
bar => 'baz',
submitted => 1,
});
$form->get_field('foo')
->get_constraint({type => 'Callback'})
->force_errors(1);
$form->process();
print $form->submitted_and_valid ? "Success\n" : "Failure\n";
print $form;
More information about the HTML-FormFu
mailing list