Form_validation - how to empty fields data after successful form submission? |
[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() {
[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
[eluser]setgreen[/eluser]
I never used flashdata before but it seems to fit my needs Thank you very much for your answer. |
Welcome Guest, Not a member yet? Register Sign In |