Welcome Guest, Not a member yet? Register   Sign In
Can not extend Form Validator core library
#1

[eluser]Neerav[/eluser]
Hello Guys,

I am using codeigniter version 2.0.

I have followed this instruction to extend core form validation library.


I try placing my new file named 'MY_Form_validation.php' inside 'application/libraries' and 'application/core' directory respectively. But neither one is working for me. I can not get my valid_url function working. Following is the content of my 'MY_Form_validation.php' file,

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

/**
* MY_Form_Validation Class
*
* Extends Validation library
*
* Adds one validation rule, valid_url to check if a field contains valid url
*/

class MY_Form_validation extends CI_Form_validation
{

    function __construct()
    {

        parent::__construct();
    }

    // --------------------------------------------------------------------

    /**
     * valid_url
     *
     * @access    public
     * @param    field
     * @return    bool
     */
    function valid_url($field)
    {
        $CI =& get_instance();

        $CI->form_validation->set_message('valid_url', 'The %s field must contain a valid url.');

        return (!preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $field)) ? FALSE : TRUE;
    }
}

// end file

I am loading form validation library in my controller and default validation methods are working fine.

Please advise me what's wrong with this or am I missing any steps.

Thanks in advance.

Regards,
Neerav


Messages In This Thread
Can not extend Form Validator core library - by El Forum - 04-11-2011, 07:08 AM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 09:07 AM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 11:13 AM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 10:48 PM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 10:55 PM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 10:59 PM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 11:08 PM
Can not extend Form Validator core library - by El Forum - 04-11-2011, 11:45 PM
Can not extend Form Validator core library - by El Forum - 04-12-2011, 03:36 AM
Can not extend Form Validator core library - by El Forum - 04-12-2011, 03:45 AM
Can not extend Form Validator core library - by El Forum - 06-01-2011, 01:37 AM
Can not extend Form Validator core library - by El Forum - 06-02-2011, 11:57 PM
Can not extend Form Validator core library - by El Forum - 06-03-2011, 02:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB