Welcome Guest, Not a member yet? Register   Sign In
Extend Form_Validation
#1

(This post was last modified: 04-04-2016, 06:53 AM by lucavalentino.)

I use Codeigniter 3.0.6
I want extend the library Form_Validation but not received a personal message error

MY_validation extends CI_Form_validation
PHP Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class 
MY_validation extends CI_Form_validation {
    function MY_validation(){
        parent::__construct();
}
    function url($str){
        $pattern "|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i";
        if (!preg_match($pattern$str)){
            $this->My_validation->set_message('url''The URL you entered is not correctly formatted.');
            return FALSE;
    }
        return TRUE;
    }


My controller
PHP Code:
class valid extends MY_Controller{
    public function 
__construct(){
    
parent::__construct();
        
$this->_CI =& get_instance();
        
$this->_CI->lang->load('upload');
        
$this->load->model('upload_m');
    }
    public function 
index(){
        
$this->load->helper(array('form''url'));
        
$this->load->library('form_validation','My_validation');
        
$this->validation->CI =& $this;
......
......
     
$this->form_validation->set_rules('sito''Sito''url');
        if (
$this->form_validation->run()==FALSE){
$this->load->view('upload_edit_view); }
}


In the View print an errors echo validation_errors(); see {url} and not  personal message.

Help me
Reply


Messages In This Thread
Extend Form_Validation - by lucavalentino - 04-04-2016, 03:11 AM
RE: Extend Form_Validation - by Tpojka - 04-04-2016, 08:53 AM
RE: Extend Form_Validation - by InsiteFX - 04-04-2016, 09:19 AM
RE: Extend Form_Validation - by lucavalentino - 04-04-2016, 02:08 PM
RE: Extend Form_Validation - by Tpojka - 04-04-2016, 03:32 PM
RE: Extend Form_Validation - by lucavalentino - 04-05-2016, 03:03 AM
RE: Extend Form_Validation - by Tpojka - 04-05-2016, 04:03 AM
RE: Extend Form_Validation - by InsiteFX - 04-05-2016, 05:52 AM
RE: Extend Form_Validation - by lucavalentino - 04-05-2016, 09:12 AM
RE: Extend Form_Validation - by InsiteFX - 04-05-2016, 10:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB