[eluser]psychoder[/eluser]
hello guys, my form validation callbacks seems not triggered...
here is the codes... im using hmvc
controller
Code:
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('message', 'Message', 'required');
$this->form_validation->set_rules('captcha', 'Captcha', 'required|callback__captcha_check');
if ($this->form_validation->run() == true)
{
$message = array(
'username' => $this->input->post('name'),
'email' => $this->input->post('email'),
'message' => $this->input->post('message'),
'date_send' => now(),
'status' => 0
);
$this->messages_model->insert_message($message);
$this->session->set_flashdata('contact_error', 'Message Sent...');
$this->session->set_flashdata('success', TRUE);
redirect('contact');
}
else
{
if ($this->captcha->create())
{
$data['captcha'] = $this->_captcha_img_html($this->captcha->html_data);
}
else
{
$data['captcha'] = 'Captcha : ' . $this->captcha->debug;
}
$data['error'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('contact_error');
$data['success'] = $this->session->flashdata('success') ? $this->session->flashdata('success') : FALSE;
$data['uname'] = array(
'name' => 'name',
'class' => 'input_text ui-widget-content ui-corner-all',
'value' => $this->form_validation->set_value('name')
);
$data['email'] = array(
'name' => 'email',
'class' => 'input_text ui-widget-content ui-corner-all',
'value' => $this->form_validation->set_value('email')
);
$data['captcha_t'] = array(
'name' => 'captcha',
'class' => 'input_text ui-widget-content ui-corner-all'
);
$data['message'] = array(
'name' => 'message',
'class' => 'form_textarea ui-widget-content ui-corner-all',
'value' => $this->form_validation->set_value('message')
);
$this->template
->title('example', 'Contact ')
->set_partial('menu', 'partials/menu')
->set_partial('footer', 'partials/footer')
->set_partial('content', 'partials/contact_form', $data)
->build('dummy');
}
callback
Code:
function _captcha_check($captcha)
{
if ($this->captcha->check($captcha))
{
return TRUE;
}
else
{
$this->form_validation->set_message('_captcha_check', 'Please enter the word correctly.');
return FALSE;
}
}