Welcome Guest, Not a member yet? Register   Sign In
Extending Native Libraries: solved
#1

[eluser]nirbhab[/eluser]
My Library:
Code:
<?php
if (!defined('BASEPATH')) exit('No direct access allowed.');
class MY_Validation extends CI_Validation {

    function MY_Validation()
    {
        parent::CI_Validation();
    }
}
?>
auto loading validation
Quote:Fatal error: Class 'CI_Validation' not found in /opt/lampp/htdocs/foodcourt/system/application/libraries/Validation.php on line 3

Any solution, or mistake i am doing?
#2

[eluser]GSV Sleeper Service[/eluser]
are you autoloading the validation library?
#3

[eluser]nirbhab[/eluser]
Yup! i am auto loading validation library
#4

[eluser]Seppo[/eluser]
Are you naming your file MY_Validation.php?
#5

[eluser]GSV Sleeper Service[/eluser]
hmmm, no idea, sorry.
I've just copied your code above and it works fine.

what is your $config['subclass_prefix'] set to?
if it's the default 'MY' then your library should be named MY_Validation.php
#6

[eluser]nirbhab[/eluser]
File name is: Validation.php
#7

[eluser]GSV Sleeper Service[/eluser]
what is your $config['subclass_prefix'] set to?
if it is still set to the default 'MY_' then this explains your problem
#8

[eluser]Seppo[/eluser]
[quote author="nirbhab" date="1206721359"]File name is: Validation.php[/quote]That is the problem. Rename it to MY_Validation.php
If you name it Validation.php CI "thinks" you overwrite the navtive validation class with one of your own. To extend it the filename must start with the prefix.

Read Creating Libraries, specially the "Extending Native Libraries" section for more info.
#9

[eluser]nirbhab[/eluser]
Thanks to all of you!

filename renamed to: My_Validation.php
I haven't checked whether my validations working or not, but i think error has resolved...so it won't further disturb :-), else i wud disturb u all again :-)




Theme © iAndrew 2016 - Forum software by © MyBB