Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Check to see if postdata is empty instead of just null #317

Closed
wants to merge 1 commit into from

2 participants

@jwensley2

Check to see if postdata is empty instead of just null, fixes fields in arrays always being required

@narfbg
Owner

empty() will return TRUE for values that are equal to boolean FALSE (e.g. '0') and can cause errors.

@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 26, 2011
  1. @jwensley2

    Check to see if postdata is empty instead of just null, fixes fields …

    jwensley2 authored
    …in arrays always being required
This page is out of date. Refresh to see the latest.
View
2  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))
{
// Before we bail out, does the rule contain a callback?
if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match))
View
1  user_guide/changelog.html
@@ -117,6 +117,7 @@
<li>Fixed a bug (#8) - <samp>load_class()</samp> now looks for core classes in <samp>APPPATH</samp> first, allowing them to be replaced.</li>
<li>Fixed a bug (#24) - ODBC database driver called incorrect parent in __construct().</li>
<li>Fixed a bug (#85) - OCI8 (Oracle) database escape_str() function did not escape correct.</li>
+ <li class="reactor">Check to see if postdata is empty instead of just null, fixes fields in arrays always being required</li>
</ul>
<h2>Version 2.0.3</h2>
Something went wrong with that request. Please try again.