Problems with extending CI_Form_validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Problems with extending CI_Form_validation (/showthread.php?tid=68572) Pages:
1
2
|
RE: Problems with extending CI_Form_validation - ardavan - 07-31-2017 (07-31-2017, 12:32 AM)Martin7483 Wrote: How are you loading the validation library? PHP Code: $autoload['libraries'] = array( RE: Problems with extending CI_Form_validation - Martin7483 - 07-31-2017 Try using the subclass_prefix MY_ RE: Problems with extending CI_Form_validation - Wouter60 - 07-31-2017 Regarding problem #1, everything looked OK to me the way you handled it in the beginning, except how you refer to the callback function. Try: PHP Code: $this->form_validation->set_rules('email', '', 'callback_scanEmail'); The function itself should keep the name 'scanEmail'. RE: Problems with extending CI_Form_validation - Martin7483 - 07-31-2017 That approach will only look for the method scanEmail in the controller where the rule was set. RE: Problems with extending CI_Form_validation - ardavan - 08-05-2017 (07-31-2017, 02:38 AM)Martin7483 Wrote: Try using the subclass_prefix MY_ if I set the prefix, then I should change my Model and core Controller which I made by myself. which I don't want this happen. Is this bug? because shouldn't be any force to have a prefix and suppose to work! RE: Problems with extending CI_Form_validation - Wouter60 - 08-06-2017 If you extend a core library by using the MY_ prefix, the extended library is loaded with the original name. So there is no need for changing your controllers or models. When you load the Form_validation library, CI will first check if there is a MY_Form_validation.php in application/libraries. If that isn't the case, it will load the core library from system/libraries. |