isset/required validation bug - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: isset/required validation bug (/showthread.php?tid=2730) |
isset/required validation bug - El Forum - 08-21-2007 [eluser]mjijackson[/eluser] This bug is discussed on this thread. In that thread, some users found a clever workaround for what is actually a bug in the code. When validation runs, it short-circuits any fields that have an 'isset' or 'required' rule if they are in fact not set. However, in the short-circuit, it neglects to set the error message for that field. This can be remedied with the following: Code: $error = $field . '_error'; It's keeping the code behavior consistent throughout the Validation class. The code should be changed around line 232 of Validation.php in order to squash the bug. isset/required validation bug - El Forum - 08-21-2007 [eluser]Derek Allard[/eluser] Thanks mjijackson. Could you post the full function that you are proposing? isset/required validation bug - El Forum - 08-22-2007 [eluser]mathgl67[/eluser] i have a litle patch for this issue. i don't know if it's fixing the whole problem. Code: diff -r 680e129277f9 -r 114fcf6410d5 system/libraries/Validation.php isset/required validation bug - El Forum - 08-22-2007 [eluser]mjijackson[/eluser] The full function is too large to post in this forum. Instead, I'll post the relevant portion. This is starting on line 206 of system/libraries/Validation.php: Code: /* The above post is also correct. isset/required validation bug - El Forum - 08-22-2007 [eluser]mathgl67[/eluser] I think the error variable should be set before building the error message. Else the error variable will be set with the text define in set_fields(). Code: // Set the error variable name. Example: $this->username_error isset/required validation bug - El Forum - 08-22-2007 [eluser]mjijackson[/eluser] The error message is supposed to contain the text defined in set fields. That's one of the reasons why that function exists. Look further down in the code and you'll see that the same thing happens a few lines further down. isset/required validation bug - El Forum - 08-29-2007 [eluser]mathgl67[/eluser] UP ! Issue need more information to be fixed ? |