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

(This post was last modified: 04-05-2016, 03:07 AM by lucavalentino.)

I try but not work.
I am using Codeigniter 3.0.6 (last version)

(04-04-2016, 03:32 PM)Tpojka Wrote:
PHP Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class 
MY_Form_validation extends CI_Form_validation
{
 
   public function __construct()
 
          parent::__construct();    }

 
   public function url($str)
 
   {
 
       $pattern "|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i";
 
       if (!preg_match($pattern$str))
 
       {
 
           $this->form_validation->set_message('url''The URL you entered is not correctly formatted.');
 
           return FALSE;
 
       
 
       else
        
 return TRUE   }
 
   }


Controller example code:

PHP Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class 
Example_c extends CI_Controller
{
 
   public function __construct()
 
   {
 
       parent::__construct();
 
       $this->load->library('form_validation');
 
   }

 
   public function index()
 
   {
 
       //echo 'Example';
 
   }


I believe that the controller does not read extensive library, but only the message from the language file
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