CodeIgniter Forums
Flow question (re-loading forms after failed validation) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Flow question (re-loading forms after failed validation) (/showthread.php?tid=10579)



Flow question (re-loading forms after failed validation) - El Forum - 08-05-2008

[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?


Flow question (re-loading forms after failed validation) - El Forum - 08-05-2008

[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.


Flow question (re-loading forms after failed validation) - El Forum - 08-05-2008

[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!