![]() |
Reset of Validation possible? - 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: Reset of Validation possible? (/showthread.php?tid=3590) |
Reset of Validation possible? - El Forum - 10-11-2007 [eluser]esbium[/eluser] Hey everyone, I have a form that submits to a controller, gets validated and then inserts the data into the database. All of that works fine. However, once all of that is done, I want to re-display the same form so the user can enter another record. When I do this, the old values from the last submit remain in the form. I do not want to use a redirect here. I have tried creating a new instance of CI_Validation after a successful submit in hopes that it would reset all the values that were stored in it but that doesn't work. Basically, the calls to $validation->someFormField return the last value from the submit. I know that this is great when there are errors, but I need to clear them if there are no errors! Please help and thanks in advance! Reset of Validation possible? - El Forum - 10-12-2007 [eluser]Luci3n[/eluser] try sub classing the validation class Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); for further info see this post Reset of Validation possible? - El Forum - 11-09-2007 [eluser]Optimus Prime[/eluser] Hi [esbium], You can try to unset the validation: Code: if ($this->validation->run() == TRUE) { This will unset the validation object, but only when validation->run() is true. In this way you can use the validation->error_string in case that validation is false. But if you need to display default values, try the Lunic3n's method. I hope this help you. |