[eluser]coolgeek[/eluser]
I've got a problem trying to extend the form validation library
Code:
<?php
class Add_member_award extends Controller {
function Add_member_award()
{
parent::Controller();
}
function index() {
$data['mview'] = "add_member_award";
$this->load->library('form_validation');
$this->form_validation->set_rules('award', 'Award', 'trim|required|xss_clean|callback_award_check');
if ($this->input->post('submit')){
if ($this->form_validation->run() == TRUE) {
$award = $this->input->post('award');
$this->load->model('Mmember_award');
$this->Mmember_award->createMemberAward($uid, $award);
redirect("member/$uid");
}
}
$this->load->vars($data);
$this->load->view('template', $data);
}
}
class MY_Form_validation extends CI_Form_validation {
function My_Form_validation()
{
parent::CI_Form_validation();
}
function award_check($str)
{
if ($str == 'test award')
{
$this->form_validation->set_message('award_check', 'The %s field can not be the word "test award"');
return FALSE;
}
else
{
return TRUE;
}
}
}
If I put function award_check in the controller, form validation triggers the check as expected. But it's not triggering it in MY_Form_validation.
What am I doing wrong here?
Thanks