2015-09-18 21 views
0

我正在使用form_validation庫來驗證我的表單。如何用代碼點火器中的FORM VALIDATION清空輸入框值

一切工作正常,但成功後,它顯示我填寫的所有值。我正在使用ci v3。我不想做一些重定向。

if ($this->form_validation->run() == True){ 
     //saving values to db 
     $this->session->set_flashdata('registration_success', '<h4 class="alert alert-success">Registration successful.. Please check your email.</h4>'); 
     $this->_field_data = array(); 
     //$this->auth(); 
    } 
+0

http://stackoverflow.com/questions/19354490/codeigniter-resetting形式值 檢查此... –

+0

**沒有重定向你想能夠得到flashdata ** –

回答

0

驗證成功後,您可以刷新頁面,這樣舊值沒有顯示出來做這樣的事情:

public function yourSaveFunction(){ 
    if ($this->form_validation->run() == True){ 
      //saving values to db 
      $this->session->set_flashdata('registration_success', '<h4 class="alert alert-success">Registration successful.. Please check your email.</h4>'); 
      $this->_field_data = array(); 
      //$this->auth(); 
      redirect('{your_current_controller_name/your_page_load_view}'); 
     } 
}