How to reset 'set_value' after valid form post |
[eluser]Hein[/eluser]
Hi all, I've tried searching for an answer on this one, but to no avail. Hope you can help. I have a form that repopulates itself with 'set_value' when errors were detected via 'form_validation'. This works fine. But when the post was successful, I want to reshow the same form. Only now I want all the fields to stay blank. Is there a way of 'resetting' the 'set_value' values? Code: <?= form_open('', array('name'=>'reaction', 'id'=>'reaction-form')); ?>
[eluser]pistolPete[/eluser]
You could redirect() to the same page in order to empty the $_POST data: http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]Hein[/eluser]
Thanks PistolPete To be honest, this one the options I thought about. But decided not to go that route since I thought it would be considered somewhat of a 'hack': -> form post -> controller (form check) -> redirect to same controller My feeling tells me that I should be trying to find a way to handle it all in one controller call. I'm interested to hear your opinion on this.
[eluser]Colin Williams[/eluser]
Redirecting after successful form posts is generally a good idea, and a good, common practice. For one, it prevents double-posting. Nothing hacky about it1
|
Welcome Guest, Not a member yet? Register Sign In |