Form_validation - how to empty fields data after successful form submission? - 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: Form_validation - how to empty fields data after successful form submission? (/showthread.php?tid=50158) |
Form_validation - how to empty fields data after successful form submission? - El Forum - 03-16-2012 [eluser]setgreen[/eluser] Hi, I'm experiencing some troubles trying to work with the Form_validation class and I hope you guys could help me. Here is the problem : I have a controller which load a view presenting a form. I use the set_value() function to repopulate the form in the view but when the form has been submitted, I would like the field to be empty again so that the user could use the form again. I know that I could do a simple redirect() to redirect to the same controller but I need to display a feedback message saying everything goes well with the form submission. That feedback message is stored in a $data['feedback'] variable, which is passed to the load view using $this->load->view(). Here is the controller code : Code: public function pages_ajout() { Form_validation - how to empty fields data after successful form submission? - El Forum - 03-16-2012 [eluser]oliur[/eluser] redirect is the way to go. Use session flash data to store a message. Code: else { Now in your view file add the following code before the form Code: // read flash data if there is any Find out more about session session flashdata Form_validation - how to empty fields data after successful form submission? - El Forum - 03-16-2012 [eluser]setgreen[/eluser] I never used flashdata before but it seems to fit my needs Thank you very much for your answer. |