[eluser]Sven Delle[/eluser]
So I:
1: Installed a clean CI 2.1.0.
2: Downloaded and implemented HMVC according to wiki.
3: Extended Form_validation class according to wiki.
4: Went through the Form Validation Tutorial, step by step.
Result: Absolutely NO callbacks!
What am I doing wrong - I assume I'm doing SOMETHING wrong - otherwise HMVC DO NOT WORK WITH callbacks!
This is my Controller:
Code:
<?php
class Admin extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->form_validation->CI =& $this;
}
public function index()
{
$this->load->view('login_form');
}
public function validate_user()
{
$this->load->helper(array('form', 'url'));
$this->form_validation->set_rules('username', 'Username', 'required', 'callback_username_check');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
if($this->form_validation->run() === FALSE)
{
$this->load->view('login_form');
}
else
{
$this->load->view('dashboard');
}
}
public function username_check($str)
{
echo 'Hello World!'; // This NEVER gets called!!!
if ($str == 'test')
{
$this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
return FALSE; // I've tried with "AAAAARGH!"
}
else
{
return TRUE; // I've also tried this with "AAAAARGH!"
}
}
}
Someone please help me, as I'm in the middle of the night. A was supposed to get things done - not trying to fix things.