[eluser]CroNiX[/eluser]
No, you're not overthinking it and I do the same. There is no reason to load the validation library, set the rules or run the validation, unless there is data to validate.
I usually do something like...
Code:
$submitted = $this->input->post('submit'); //my submit button
if ($submitted)
{
$this->load->library('form_validation');
$this->form_validation->set_rules();
if ($this->form_validation->run() !== FALSE)
{
//passed - maybe redirect, or add flashdata success message
}
else
{
//failed - add flashdata failure message
}
}
//load the main view.
$this->load->view();
1) form comes up clean upon initial page load
2) if submitted, load and run validation
3) if errors, show errors and general error message
4) if passes, show success message...possibly redirect. Depends on case.