CodeIgniter Forums
callback not being called - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: callback not being called (/showthread.php?tid=37479)



callback not being called - El Forum - 01-11-2011

[eluser]Unknown[/eluser]
Hi, I need help with this, i dunno why the callback not being called.

Code:
class C_registro extends Controller {
        
        function C_registro()
        {
            parent::Controller();
            $this->load->helper(array('url','form'));
            $this->load->library('form_validation');
            $this->load->database();
            $this->load->model('m_user');
        }
                function index()
        {
            $this->registrar();
        }
//-------------------------------------------------------------------------------------------------        
        function mostrarRegistro()
        {
            $datos = array(
                    'titulo'     => "Registro de Usuario",
                    'url'         => $this->config->item('path_url'),
                    'jquery'     => $this->config->item('path_jquery'),
                    'jquery_ui' => $this->config->item('path_jquery_ui'),
                    'ui_css'     => $this->config->item('path_jquery_ui_css')
                );
                    
            $this->load->view('v_registro',$datos);
        }
//-------------------------------------------------------------------------------------------------        
        function registrar()
        {
            $this->form_validation->set_rules('nombre','Usuario','trim|required|min_length[3]|max_length[50]|callback_username_check');
            $this->form_validation->set_rules('pass'  ,'ContraseƱa','trim|required|min_length[8]|max_length[50]|alpha_numeric|MD5');
            
            $this->form_validation->set_error_delimiters('<div class="ui-state-error ui-corner-all" align="center">', '</div>');
            
            if($this->form_validation->run() == FALSE)
            {
                $this->mostrarRegistro();
            }
            else
            {
                redirect('ok');
            }        
        }
    }
//-------------------------------------------------------------------------------------------------
        function username_check($usr)
        {
            $this->form_validation->set_message('username_check', 'The callback was called.');
        return FALSE;
            /*
            $existe = $this->m_user->existeUser($usr);
            if ($existe)
            {
                $this->form_validation->set_message('username_check', 'El usuario ya existe');
                $rtrn = FALSE;
            }
            else
            {
                $this->m_user->altaUser($usr,$this->input->post('pass'));
                $rtrn = TRUE;
            }
            
            return $rtrn;
            */
        }
//--------------------------------------------------------------------------------



callback not being called - El Forum - 01-11-2011

[eluser]mi6crazyheart[/eluser]
Hey u might've kept u'r callback function out side of class. Bring that inside of the class...