Form Validation - set_value() working differently in v3 |
I'm using CodeIgniter v3 on a new project and noticed that Form Validation in conjunction with set_value() is not working the same as it did in CodeIgniter v2.
In CI version 3, set_value() is totally ignoring an empty string on a "required" validation error, where CI v2 did not. The scenario is a form that can be used to "edit" existing data. The page loads with the form fully populated with data. Let's say every field is already set as "required". Consider the following code... Code: <?php $first = isset($first) ? $first : ''; ?> In CodeIgniter v2: if you blank out a few fields and hit submit, when the page reloads, you'll see validation errors, and the blanked out fields remain blank until you fix them. In CodeIgniter v3: if you blank out a few fields and hit submit, when the page reloads, you'll see validation errors, but the blanked out fields reload with their original values; not blank as expected.
So with the "required" rule on an empty field, set_value() simply ignores the empty string and reverts to the original value on a failed validation reload. Under CI v2 it would load with the empty string (blank field) on a failed validation. Is this new behavior an intentional or is this a bug? The v3 documentation for set_value() is the same as v2 Thank-you! |
Welcome Guest, Not a member yet? Register Sign In |