blank set_value() return default value |
After digging through the core of CI 2.2 and CI 3, there are one small difference in the code that seems to be creating this issue.
In CI 3, in system/libraries/Form_validation.php line 941 the set_value() method check if the field exists and have any postdata PHP Code: if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) The same code in CI 2.2 only check if the field exists, but not if it has any content. Line 732. PHP Code: if ( ! isset($this->_field_data[$field])) When form validation is executed with run(), it does not set the postdata for a field if it is empty. CI 3 system/libraries/Form_validation.php line 466 PHP Code: elseif (isset($validation_array[$field]) && $validation_array[$field] !== '') This is the same in both CI 2.2 and CI 3. So due to that CI 3 check if the field has any data, which it don't have if submitted empty, it returns the default field value. Sum up Both CI 2.2 and CI 3 sets the postdata in the same way when using the form validation on form submission. But a change in CI 3, namely the adding of checking if a field have any postdata, returns the fields default value if that field was submitted empty. |
Messages In This Thread |
blank set_value() return default value - by Reirei - 04-01-2015, 04:57 PM
RE: blank set_value() return default value - by mnolte - 04-04-2015, 07:55 AM
RE: blank set_value() return default value - by mnolte - 04-04-2015, 07:57 AM
RE: blank set_value() return default value - by Reirei - 04-09-2015, 06:19 PM
RE: blank set_value() return default value - by silentium - 04-10-2015, 10:05 AM
RE: blank set_value() return default value - by Reirei - 04-12-2015, 08:20 AM
RE: blank set_value() return default value - by silentium - 04-12-2015, 10:59 AM
RE: blank set_value() return default value - by Reirei - 04-13-2015, 03:35 PM
RE: blank set_value() return default value - by silentium - 04-13-2015, 04:41 PM
RE: blank set_value() return default value - by sparky672 - 05-01-2015, 07:12 AM
RE: blank set_value() return default value - by Reirei - 05-14-2015, 06:22 PM
|