Welcome Guest, Not a member yet? Register   Sign In
Extended MY_Form_validation not working
#1

[eluser]a_bains[/eluser]
Hello,

I am using CodeIgniter 2.0 and I am trying to extend the Form Validation library.

In my controller I am loading the library like this: $this->load->library('form_validation');

I am able to use my extended function when I place the MY_Form_validation.php file into the libraries folder. But when I put into the applications/core folder it doesn't recognize my extended function... I would like to keep all the MY_ classes in the core folder because I think thats the what the best practice is and it keeps my files organized.

Here is the MY_Form_validation.php code:

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

/**
* MY_Form_validation Class
*
* Extends Form_Validation library
*
* Allows for custom error messages to be added to the error array
*
* Note that this update should be used with the
* form_validation library introduced in CI 1.7.0
*/
class MY_Form_validation extends CI_Form_validation {

    function __construct()
    {
        parent::__construct();
    }

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

    /**
     * Set Error
     *
     * @access  public
     * @param   string
     * @return  bool
    */  

    function set_error($error = '')
    {
        if (empty($error))
        {
            return FALSE;
        }
        else
        {
            $CI =& get_instance();

            $CI->form_validation->_error_array['custom_error'] = $error;

            return TRUE;
        }
    }

}

?>


Messages In This Thread
Extended MY_Form_validation not working - by El Forum - 02-23-2011, 10:27 PM
Extended MY_Form_validation not working - by El Forum - 02-24-2011, 10:11 AM
Extended MY_Form_validation not working - by El Forum - 02-24-2011, 02:57 PM
Extended MY_Form_validation not working - by El Forum - 02-25-2011, 02:30 AM
Extended MY_Form_validation not working - by El Forum - 02-25-2011, 09:20 AM
Extended MY_Form_validation not working - by El Forum - 02-25-2011, 10:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB