Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.3.2

Request #9097 option to execute rules even when element values are empty
Submitted: 2006-10-19 19:56 UTC
From: marcio at corp dot grupos dot com dot br Assigned: avb
Status: Closed Package: HTML_QuickForm2
PHP Version: 4.4.4 OS: freebsd
Roadmaps: 0.2.0    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2007-10-15 12:03 UTC
Package:
Bug Type:
Summary:
From: marcio at corp dot grupos dot com dot br
New email:
PHP Version: Package Version: OS:

 

 [2006-10-19 19:56 UTC] marcio at corp dot grupos dot com dot br (Márcio Dick Smiderle)
Description: ------------ Class Rules needs and attribute (validateIfEmptyValue, by default false) that says to validate() execute that rule even when the element has an empty value. Now it is hardcoded for required and uploadedfile, in addRule(). These rules should set validateIfEmptyValue attribute to true. I need ( :) ) that when i created a rule called requiredIfCompare, where an elemento should be required only if some comparison of other elements results true. It could be in QF 3, next version ;~

Comments

 [2007-07-06 20:58 UTC] molecularbear (Ross Davis)
I agree 100%. Much flexibility can be gained by allowing a way to lift the validation ban on not-required-and-empty fields. The aforementioned solution should work just fine without breaking anything.
 [2007-10-15 12:03 UTC] avb (Alexey Borzov)
Implemented in CVS. In QuickForm2 the rules themselves contain code to decide whether empty elements should be validated or not. Currently Length, Regex, MaxFileSize and MimeType rules do not try to validate empty fields and will return true for them, all other rules will validate. One can prevent validation of empty values by rule chaining, e.g.: $field->addRule('empty') ->or_($field->createRule('gt', 'Should be positive', 0));