gshank/html-formhandler

Call of dump_validated() fails on form which has inactive fields

dionys opened this issue · 1 comments

This code raises exception Cannot delegate has_errors to has_errors because the value of result is not defined:

HTML::FormHandler
    ->new(
        field_list => [
            foo => {},
        ],
    )
    ->process(
        inactive => ['foo'],
        posted   => 1,
        verbose  => 1,
    );

Exception raised in HTML::FormHandler::Fields::dump_validated() by call has_error method on inactive field:

foreach my $field ( $self->all_fields ) {
    ...
    my $message = $field->has_errors ? join( ' | ', $field->all_errors) : 'validated';
    ...
}

In inactive fields the value of result attribute is not defined. So call of has_error on this field raises exception because has_error delegates to result.

You need to use $self->sorted_fields in foreach-loop. Or you need to check that the field is active.

Fixed a while back.