Welcome Guest, Not a member yet? Register   Sign In
Validation error
#1

when extend form_validation library error message is not shown.
my_validation library
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class My_validation extends CI_Form_validation
{

    public function test()
    {
        return true;
    }
}



form controler

class Form extends CI_Controller {
    
         public function __construct()
        {
                parent::__construct();
                $this->load->helper(array('form', 'url'));
                $this->load->library(array('form_validation','my_validation'));
        }

        public function index()
        {
            $this->my_validation->set_rules('first_name', 'First Name', 'required|alpha');
            
            /*$this->my_validation->set_rules('last_name', 'Last Name', 'required|alpha');
            $this->my_validation->set_rules('user_type', 'User Type', 'required|integer');
            $this->my_validation->set_rules('user_name', 'User Name', 'required|alpha_numeric');
            
            $this->my_validation->set_rules('user_password', 'Password', 'required|alpha_numeric');
            $this->my_validation->set_rules('confirm_password', 'Confirm Password', 'required|alpha_numeric|matches[user_password]');
            $this->my_validation->set_rules('email', 'email', 'required|valid_email');
            $this->my_validation->set_rules('contact_no', 'Contact No', 'required|numeric|exact_length[10]');*/
            //$this->my_validation->set_rules('upload_img', 'Image', 'file_empty_check');
                 /*
                $config['upload_path']          = './uploads/';
                $config['allowed_types']        = 'gif|jpg|png';
                $config['max_size']             = 100;
                $config['max_width']            = 1024;
                $config['max_height']           = 768;
                $this->load->library('upload', $config);*/
                if ($this->my_validation->run() == FALSE)
                {
                    
                
                
                
                    $this->load->view('myform',$data);
                }
               /* else
                {
                    $this->load->model('registration_model');
                    $this->db->trans_begin();
                    $this->registration_model->new_registration();
                    $this->registration_model->insert_login();
                    if ($this->db->trans_status() === TRUE && $this->upload->do_upload('upload_img'))
                    {
                        $this->db->trans_commit();
                        
                    }
                    else
                    {
                        $this->db->trans_rollback();
                    }
                }*/
            
            
        }
        
        
        
}




form view

<?php


echo  validation_errors();

?>

Please help.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB