CodeIgniter Forums

Full Version: Issue with form validation and page content restarting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Basically, I have my controller function for adding in my case a page but let's focus on the function:

Code:
public function add() {
  $this->session->unset_userdata('postID');

  if ($this->form_validation->run() == TRUE) {
    // Form Validation
  }
  $this->data['subview'] = 'blah blah';
  $this->load->view('blah blah.php', $this->data);
}

Basically when the form is submitted it will still unset the postID in this case, however i want to ensure that if the form is submitted and there are errors that this is missed and it doesn't redo some of my functions and variables. This is happening for a lot of my content when the form is submitted it re-initiates variables that i want to be ignored.

I also tried the following but it didn't work either:

Code:
if (!$this->form_validation->run() {
  $this->session->unset_userdata('postID');
}

How do i avoid the entire page being redone with form validation?

Thanks

El Forum

[eluser]InsiteFX[/eluser]
Check for the submit button then you can change the form values that you want see the form_helper etc;
Use the set_value