Reset of Validation possible? |
[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!
[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
[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. |
Welcome Guest, Not a member yet? Register Sign In |