[html-formfu] form still valid after force_error()
Carl Franks
fireartist at gmail.com
Tue Mar 11 07:29:52 GMT 2008
On 09/03/2008, Steve Caldwell <info-formfu at caldwellhb.com> wrote:
> 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)?
force_errors is really only intended to affect the xhtml output.
The only way to return them in your code is with get_errors({ forced => 1})
(note that that returns all errors, not just forced ones)
There's currently no way to make has_errors() or submitted_and_valid()
take them into account.
The equivalent to submitted_and_valid() would be:
if ( $form->submitted && @{ $form->get_errors({forced=>1}) } ) {
...
}
Carl
More information about the HTML-FormFu
mailing list