Welcome Guest, Not a member yet? Register   Sign In
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');
    }        
}




Theme © iAndrew 2016 - Forum software by © MyBB