Welcome Guest, Not a member yet? Register   Sign In
Re-populating the form after CI validation fails
#11

[eluser]bidur[/eluser]
Hi all,
now I need some way to clear the data.
My scenario is as follows:
After the validation work is complete the validated data is entered into the database by the function entry_insert() from the MODEL. After this again the initial form is displayed with all the default data.
My problem is that the form contains the data that is entered by the user before.(this is due to the data re-population code that is to be used when validation fails) Is there some way to clear the user inputted data from the form ?

thank you
#12

[eluser]bidur[/eluser]
Hi all,
I got a solution to the above problem.
I am posting my solution, so that I can get feedback whether I am doing it correctly or not.
Again, it might help some newbies like me in some way..

After inserting data in the database. I added this line to the end of the function entry_insert()
Code:
function entry_insert()
  {    
  //code to insert data to database
  
  redirect('/Email_controller/email');
  exit;
  }

This solved two of my problems:
1. Clearing the user submitted values from the form after the data is inserted into the database.
(as i have stated in the last post in this thread)
2. After the user submitted data is entered into the database, it used to get re-entered into the database
each time I hit the refresh button. Now, this problem is also solved.

Thank You




Theme © iAndrew 2016 - Forum software by © MyBB