Welcome Guest, Not a member yet? Register   Sign In
Problems with extending CI_Form_validation
#11

(07-31-2017, 12:32 AM)Martin7483 Wrote: How are you loading the validation library?

PHP Code:
$autoload['libraries'] = array(
 
'database'
 
'email'
 
'session'
 
'form_validation'
 
'pagination'
 
'encryption'); 
Reply
#12

Try using the subclass_prefix MY_
Reply
#13

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'.
Reply
#14

That approach will only look for the method scanEmail in the controller where the rule was set.
Reply
#15

(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!
Reply
#16

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB