Welcome Guest, Not a member yet? Register   Sign In
If form validation fails
#2

[eluser]PhilTem[/eluser]
I always have my controller first check if there was anything submitted in $_POST before I perform the form-validation. This way, the form-validation is not executed on the initial page loading. The code is something like this

Code:
if ( $this->input->post('name_of_submit_btn') )
{
  if ( $this->form_validation->run() === TRUE )
  {
    // Do whatever
  }
  else
  {
    // Set a flash message
  }
}

// Show form

In your case, you might also first wanna try to type-sensitive check for TRUE and for FALSE i.e.
Code:
if ( $this->form_validation->run() === TRUE )
{
  redirect();
  exit();
}


Messages In This Thread
If form validation fails - by El Forum - 01-11-2013, 06:01 AM
If form validation fails - by El Forum - 01-11-2013, 06:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB