[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->error();
My URL will look like
sitename/contact/process
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']);
redirect('contact/error');
My URL will look like
sitename/contact/error and is more appropriate.
3. set flash_data and redirect to a new 'error' controller
Code:
$this->session->set_flashdata('Database', $this->lang->language['db_error_heading']);
redirect('error');
My URL will look like
sitename/error and is more appropriate.(I think)
All of the above have pro's and con's, please advise me.
Thanks in advance.
regards
Alaric