Welcome Guest, Not a member yet? Register   Sign In
controler function question
#1

[eluser]quasiperfect[/eluser]
hi

in a controller we can have the validation function callbacks.
if we call the controller site/controller/function we get the php errors
how can i avoid this ? (i don't need/want to call the functions but if someone dose)
#2

[eluser]drewbee[/eluser]
Yes.
#3

[eluser]quasiperfect[/eluser]
yes what ?
#4

[eluser]drewbee[/eluser]
I would love to help you, but I am not sure what you are asking.

Do you mean you do not want to be able to access the callback functions via the url?

Prefix your callback functions with a _ IE
Code:
function _myCallback($val)
{

}

This will make it private and no longer accessible via the url.
#5

[eluser]quasiperfect[/eluser]
that's what i want but if i use _ before the function name then the function doesn't get called

example normal use but the problem with enyone can call the controller/field_check url
Code:
$this->form_validation->set_rules('field', 'Field name', 'callback_field_check');
function field_check($str){
blah blah
}

like u said the function doesn't get called
Code:
$this->form_validation->set_rules('field', 'Field name', 'callback_field_check');
function _field_check($str){
blah blah
}

if i modify the code like this it works but we have to modify everything with a _ and for a big site that's not something i would love to do any other solution available ?
Code:
$this->form_validation->set_rules('field', 'Field name', 'callback__field_check');
function _field_check($str){
blah blah
$this->form_validation->set_message('_field_check', 'error mesage');
}
#6

[eluser]drewbee[/eluser]
when your calling the callback, you need to use two underscores...

Code:
$this->form_validation->set_rules('field', 'Field name', 'callback__field_check');

As for other ideas, this is how code igniter has been since I have used it. It really isn't that hard of a change just pop open all your controllers and add an extra _ infront of all functions and a _ infront of the rule setting.
#7

[eluser]dmiden[/eluser]
Using double underscore is the optimal and correct solution quasiperfect.
I really don't see a problem with it?
#8

[eluser]quasiperfect[/eluser]
ok thanks for u'r responses i will use the '_' untill i find a better solution




Theme © iAndrew 2016 - Forum software by © MyBB