• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How To Clear Data in Form_validation?

#1
[eluser]NotoriousWebmaster[/eluser]
Instead of going to a separate page on successfully writing the form's data to the DB, I'd like to return to the same page, so the user can add another record; but I want the data fields to be empty. I'm using the value="<?= set_value('field_01') ?>". So how do I clear that data out?

Thanks for your help,
- AAA

#2
[eluser]cideveloper[/eluser]
just redirect back to the "controller/function" that displays the form.

Code:
function function1() {
    if ($this->form_validation->run() == FALSE)
    {
        $data = array (
            '' => ''
        );
        $this->load->vars($data);
        $this->load->view('form');
    }
    else
    {
        $result = $this->model->add2db($this->input->post('field_01', TRUE));
        redirect('/controller/function1');
    }        
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.