[eluser]prestondocks[/eluser]
Hi All,
I understand that there is a bug when using a callback function with HMVC and there is a hot fix for this issue. I have applied the hot fix by using the My_Form_validation.php documented on a number of sites.
I am using codeigniter1.7.2 and callback is not working for me. The callback function is not being called at all. At this point I am pulling my hair out. Could someone check the code below and let me know if I am doing something silly. All other validation rules are working.
This is the function that should contains the callback.
Code:
function profile()
{
if(!$this->input->post('submit'))
{
$view_data = array(
'page_title' => 'User Profile',
'content_file' => 'profile',
'form_data' => $this->users_model->get_user($this->session->userdata('username')),
);
$this->load->view('themes/default/index.php',$view_data);
}
else
{
$this->form_validation->set_rules('username','Username','required|callback_username_check');
$this->form_validation->set_rules('firstname','First name','required');
$this->form_validation->set_rules('lastname','Last name','required|min_length[3]|max_length[20]');
$this->form_validation->set_rules('email','Email','required|valid_email');
if ($this->form_validation->run($this)==FALSE)
{
$view_data = array(
'page_title' => 'User Profile',
'content_file' => 'profile',
);
$this->session->set_flashdata('error','Please correct the errors');
$this->load->view('themes/default/index.php',$view_data);
}
else
{
$this->users_model->update_profile();
$userdata = $this->users_model->get_user($this->input->post($this->input->post('username')));
$this->session->set_userdata($userdata);
redirect('users/profile');
}
}
}
This is the call back function. I have put a return false on the first line but it still does not work.
Code:
function username_check($str)
{
return false;
$this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
return $this->users_model->username_unique($str);
}