Ticket #149 (closed defect: fixed)
Non-required date elements are validated against min and max dates
| Reported by: | frank.kleine@… | Owned by: | argh |
|---|---|---|---|
| Priority: | highest | Milestone: | v0.9.0 stable |
| Component: | Element | Version: | current-cvs |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by schst) (diff)
When it comes to validation of a submitted form the date element will be validated against minmum and maximal date values, regardless if the element is required or not. In cases where its not required this leads to situations where you get error messages for dates out of this min and max borders which may confuse the user because it was not needed to set the date right.
Solution: in patForms_Element_Date::validateElement() replace
if( $required && is_null( $value ) )
with
if( !$required ) {
return true;
} elseif( $required && is_null( $value ) )
Change History
comment:2 Changed 8 years ago by argh
- Owner changed from argh@… to argh
- Status changed from new to assigned
if( !$required ) {
return true;
}
would not be sufficient - if a field is not required, you don't have to fill it out. But if you fill it out anyway, the data has to be valid nonetheless. I suggest doing this:
if( !$required && is_null( $value ) ) {
return true;
}
That way the field will be skipped when empty and not required, but will be validated if a value has been set.
