• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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