CodeIgniter Forums
How to extend a class from the library? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to extend a class from the library? (/showthread.php?tid=28279)



How to extend a class from the library? - El Forum - 03-06-2010

[eluser]Sinclair[/eluser]
Hi,

I need to validade International characters in the Form Validation Class.

I need to change the a class function from:

Code:
function alpha($str)
{
return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
}

to

Code:
function alpha($str)
{
return ( ! preg_match("/^([*A-Za-zá-úÁ=Ú.\s*])+$/i", $str)) ? FALSE : TRUE;
}

But if I do this. The next time I upgrade Codeigniter I broke it. How can I extend this class?

PS: Newbie in OOP.


Best Regards,


How to extend a class from the library? - El Forum - 03-06-2010

[eluser]2think[/eluser]
Here is a helpful section in the userguide on extending libraries

http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html

Not sure but here is the section on Helpers, just in case you find it easier/better to make your own.

http://ellislab.com/codeigniter/user-guide/general/helpers.html

Hope those help some.