![]() |
Need advice on form error handling - 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: Need advice on form error handling (/showthread.php?tid=45511) |
Need advice on form error handling - El Forum - 09-24-2011 [eluser]Unknown[/eluser] Hi all, I'm quit new to CI and love the framework. Since I'm rewriting my current website to a new multilingual with modern features, I question myself on how to do the form error handling best (whats best practice) in CI. Keep in mind that (later on) I want to add AJAX to the form (which is completely new to me). Your advise/suggestions are more than welcome and very appreciated. I submit the form like this Code: <?= form_open('contact/process', array('id' =>'Myform')); ?> When something goes (technically) wrong (validation or database) I have a few options; 1. set error data and jump to an errorfunction ie: Code: $this->errData['errorMessage'] = $this->lang->language['db_error_heading']; This has a disadvantage that the url is not changed (I would like to see contact/error), because this is more clear to the user (I think) 2. set Flash_data and redirect to the errorfunction ie: Code: $this->session->set_flashdata('Database', $this->lang->language['db_error_heading']); 3. set flash_data and redirect to a new 'error' controller Code: $this->session->set_flashdata('Database', $this->lang->language['db_error_heading']); All of the above have pro's and con's, please advise me. Thanks in advance. regards Alaric |