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  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 11 + 14 = ?

 
 [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));