Welcome Guest, Not a member yet? Register   Sign In
codeigniter 1.7.2 hmvc and form_validation callback
#1

[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);
    }


Messages In This Thread
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 07-29-2010, 01:15 AM
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 07-29-2010, 09:46 AM
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 07-29-2010, 12:20 PM
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 07-29-2010, 12:23 PM
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 07-29-2010, 01:16 PM
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 08-11-2010, 10:27 PM
codeigniter 1.7.2 hmvc and form_validation callback - by El Forum - 08-11-2010, 11:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB