Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the HTML-FormHandler CPAN distribution.

Report information
The Basics
Id: 64725
Status: resolved
Priority: 0/
Queue: HTML-FormHandler

Owner: Nobody in particular
Requestors: maz [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: Compound Field Bug
Date: Thu, 13 Jan 2011 09:12:41 +0800
To: bug-HTML-FormHandler [...]
From: John Maslanik <maz [...]>
Download (untitled) / with headers
text/plain 1.3k
Summary: Subfields of a compound field do not validate if all subfields of a compound are blank. Version: 0.32005 (latest) How to reproduce: Create a compound field with sub fields, make one of the sub fields "required", process the form with the compound field and all of the sub fields blank, the form will pass validation even though the "required" subfield is blank. Details: I tracked the problem down to the validate_field sub in FormHandler:Validate line 54. $field->input_defined is called at line 71 which is defined in HTML::FormHandler::Field line 516. input_defined then returns the results for has_some_value which is defined in HTML::FormHandler::Validate::Actions line 148. As you can see if you examine the has_some_value function, 0 is returned if the value is a has and non of the members contain a value, which is the case for a compound field with none of the subfields filled in. This prevents the $field->_fields_validate function in HTML::FormHandler::Validate from being called which would validate all the subfields. Proposed Solution: Add the following: elsif ( $field->DOES('HTML::FormHandler::Field::Repeatable') ) { } on line 67 of HTML::FormHandler::Validate right after the line that reads: elsif ( $field->DOES('HTML::FormHandler::Field::Compound') ) { } Attached is a test that exhibits the bug:
Download compound_bug.t
text/x-perl 925b

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 515b
Normally for a compound field, in order to do specific validation on subfields, the compound field must be set to 'required' also. This is because in some circumstances, the 'required-ness' of the subfields should only take effect if the record exists at all; it doesn't apply to empty records. So for this case, you should set the Repeatable field to 'required'. Note that for repeatables this would mean that you couldn't have empty repeatables, which is something that's done fairly often with this field type.
Closing old bug report

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to