[eluser]piddleton[/eluser]
I'm just about finished implementing the CI captcha helper on my form. So far, so good, but as I near the end and test validation for not only captcha, but the other input fields, a question came up with regard to validation.
I use a controller to process the form input variables:
Code:
$this->form_validation->set_rules('user', 'Name', 'trim|required');
.
.
if($this->form_validation->run() == FALSE)
{
$data = $this->contact_model->get_captcha_word();
$this->load->view('contact',$data);
}
Then if there are validation errors, my view has this code to display the errors above the form:
Code:
echo validation_errors('<p class="error">');
My issue is that the validation for the captcha processing (I used the code sample from the user guide to validate) takes place outside of form_validation->set_rules. So as of now, if there are errors on the 'user' field AND errors on the captcha match, the view only shows the 'user' error message.
I can't seem to get both error messages to appear above the form if there are both errors on the 'user' and captcha fields.
Is the best way to do this to create a custom callback function for the captcha validation? Or could I put the captcha validation process before form_validation->run() executes and somehow append the captcha error to validation_errors?