[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;
}
}
}
?>