![]() |
How to reset 'set_value' after valid form post - 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: How to reset 'set_value' after valid form post (/showthread.php?tid=23024) |
How to reset 'set_value' after valid form post - El Forum - 09-27-2009 [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')); ?> How to reset 'set_value' after valid form post - El Forum - 09-27-2009 [eluser]pistolPete[/eluser] You could redirect() to the same page in order to empty the $_POST data: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html How to reset 'set_value' after valid form post - El Forum - 09-28-2009 [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. How to reset 'set_value' after valid form post - El Forum - 09-28-2009 [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 How to reset 'set_value' after valid form post - El Forum - 09-28-2009 [eluser]Hein[/eluser] @Colin: thanks! Then that's the way to go. |