Fixed issue #113 - Input fields are automatically required #526

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@chrisberthe
Contributor

Issue #113

@GreenImp

@EllisLab - Is this pull requests going to be included at some point? It fixes a rather irritating bug and would be much appreciated

@narfbg
Contributor
narfbg commented Jun 13, 2012

@GreenImp This pull request currently can't be merged as it's in conflict with the current code base. Basically - it's based on the 2.1.0 release but is targeted at the code that would be released as 3.0. With that said - there have been a lot of changes made and you should try and see if the code in the develop branch here doesn't fix it. (Please leave a comment here afterwards, if you do that)

Also, this would fix issue #113, but would cause another bug - empty() matches any empty value, such as '0' and '0.0', so in those cases it could skip a 'numeric', or 'natural' rule for example.

@GreenImp

Thanks very much for your response. That makes perfect sense, I notice that you've also re-opened the issue.
I will give the develop branch a try, if I get the chance.. unfortunately it's rather busy here!

Cheers

@Dentxinho Dentxinho commented on the diff Jul 26, 2012
system/libraries/Form_validation.php
@@ -485,7 +485,7 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
// If the field is blank, but NOT required, no further tests are necessary
$callback = FALSE;
- if ( ! in_array('required', $rules) AND is_null($postdata))
+ if ( ! in_array('required', $rules) AND empty($postdata))
@Dentxinho
Dentxinho Jul 26, 2012 Contributor

To fix issue #113 properly, change this line to:

if ( ! in_array('required', $rules) AND in_array($postdata, array('', FALSE, NULL), TRUE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment