• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flow question (re-loading forms after failed validation)

#1
[eluser]absurdparadox[/eluser]
First, allow me to state that I am an experienced web developer, however I have very little PHP experience (I have like 8 years experience in CF... good CF, not the crap-code that makes non-CF developers hate CF). So, I'm using Ci to sort of jump-start my PHP learning... when learning a new language, I find its more of a difficulty with methodology than syntax itself, so I thought this would be a good road to take.

Anyway, I'm trying to figure out how to pass the user back to the form with the form preloaded with the info they entered after their data has failed validation. Right now, what I'm doing is the following (this is a simplified version of the code for method example, so please ignore syntax errors):

Code:
if(validationsuccessful){
redirect('/controller/whatever');
} else {
$data['errormessage'] = 'Validation failed!';
$data['formvar'] = $submittedvar;
$data['formvar'] = $submittedvar;
$data['formvar'] = $submittedvar;
$this->load->view('form_view',$data);
}

Is there a better/easier way to be doing this?

#2
[eluser]Jason McIntosh[/eluser]
Have a look at the CI Validation class, down at the bottom of the page. That might be what you're looking for.

#3
[eluser]absurdparadox[/eluser]
Yep, thanks. My brain is so fried, and I thought I already went through that completely and assumed it wasn't there. Funny, considering "RTFM" questions are a pet peeve of mine, hah. Sorry!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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