Welcome Guest, Not a member yet? Register   Sign In
[solved] private function in MY_Controller
#1

[eluser]kaejiavo[/eluser]
Hi guys,

i am using a callback function for form validation in a couple of controllers. Since I don't want it accessible from the web i named it
Code:
function _user_check() {...}

I put it in MY_controller, but then when i use it from a controller it is simply not called.

Is there any way to have a function in MY_Controller that is not accessible from the web?

TIA,
Marco
#2

[eluser]WanWizard[/eluser]
callback, as in Form_validation callback?

Remember that since it starts with an underscore, you have to define it in your rule as 'callback__user_check', so with TWO underscores.
#3

[eluser]kaejiavo[/eluser]
[quote author="WanWizard" date="1287870167"]callback, as in Form_validation callback?[/quote]
exactly.

It works very well if i have the function in the controller, but doesn't work if i declare the function in MY_Controller...

Marco
#4

[eluser]kaejiavo[/eluser]
my code in controller:

Code:
class Mail extends Member_Controller {

...

    function send()
    {
        // set validation rules for form processing

        $this->form_validation->set_rules('to_id', 'to_id', 'required|is_numeric|callback__user_check');
        $this->form_validation->set_rules('subject', 'subject', 'required|max_length[45]');
        $this->form_validation->set_rules('text', 'text', 'required|max_length[255]');
...

Member_controller extends MY_Controller. If i put _user_check() there, it doesn't work.

Marco
#5

[eluser]kaejiavo[/eluser]
AHH, my mistake.
I put the function in the wrong base controller. After double checking it and putting it correctly into MY_Controller everything works fine.

Marco




Theme © iAndrew 2016 - Forum software by © MyBB