EllisLab/CodeIgniter — pull request #2322 by deed02392 (2013-03-11 20:58:06+00:00)
Title: Fix issue with validation of array _REQUEST input

If you're on a page which doesn't currently contain an input type, for example $_POST['itemno[]'], but sometimes that controller DOES receive a post item of that name, a bug exists.

Since sometimes that controller does receive it you might set a validation rule on it.

When CI initialises the set_rule for that field, it detects if it's an array and hence adds it to the fielddata array regardless of whether any data was actually submitted.

It sets [$field]['postdata'] to NULL because of cause it doesn't actually know if data is submitted.

But then when it comes to setting the default value, if you're moving to a page which now DOES have this form element, set_value sets the field to '' because the first check sees that the element isset.

By checking if the postdata was actually NULL, you can hence allow CI to set the appropriate default value for the element, which is correct because no data has been submitted if postdata hasn't changed from NULL.