Welcome Guest, Not a member yet? Register   Sign In
Form Validation and callbacks
#1

[eluser]kilishan[/eluser]
Hey gang, Working on an issue with Bonfire and it seems that the form_validation callbacks aren't working any more. I could have sworn I had these working before, but now they don't even appear to be called. Am I missing something here?

Code:
if ($this->input->post('submit'))
        {
            // Validate input
            //$this->form_validation->set_rules('email', 'Email', 'required|trim|callback_unique_email|strip_tags|valid_email|max_length[120]|xsx_clean');
            $this->form_validation->set_rules('email', 'Email', 'callback_unique_email');
            if (config_item('auth.use_usernames'))
            {
                $this->form_validation->set_rules('username', 'Username', 'required|trim|strip_tags|max_length[30]|callback_unique_username|xsx_clean');
            }
            $this->form_validation->set_rules('password', 'Password', 'required|trim|strip_tags|min_length[8]|max_length[120]|xsx_clean');
            $this->form_validation->set_rules('pass_confirm', 'Password (again)', 'required|trim|strip_tags|matches[password]');
            
            if ($this->form_validation->run() !== false)
            {
                // Time to save the user...
                $data = array(
                    'email'        => $_POST['email'],
                    'username'    => isset($_POST['username']) ? $_POST['username'] : '',
                    'password'    => $_POST['password']
                );

                if ($this->user_model->insert($data))
                {
                    redirect('login');
                }
            }
        }
    
        Template::set_view('users/users/register');
        Template::set('page_title', 'Register');
        Template::render();
    }
    
    //--------------------------------------------------------------------
    
    public function unique_email($email)
    {
        if ($this->user_model->is_unique('email', $email) === true)
        {
            return true;
        }
        else
        {
            $this->form_validation->set_message('unique_email', 'That email address is already in use.');
            return false;
        }
    }
    
    //--------------------------------------------------------------------


Messages In This Thread
Form Validation and callbacks - by El Forum - 04-05-2011, 07:57 AM
Form Validation and callbacks - by El Forum - 04-05-2011, 10:02 AM
Form Validation and callbacks - by El Forum - 04-05-2011, 10:09 AM
Form Validation and callbacks - by El Forum - 04-05-2011, 10:22 AM
Form Validation and callbacks - by El Forum - 04-05-2011, 11:26 AM
Form Validation and callbacks - by El Forum - 04-05-2011, 11:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB