• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Private function and Custom form validation

#1
[eluser]BenAbrams[/eluser]
Hi Guys

I have a custom field validation rule in a config file set up, something similar to to the below:

Code:
array(
     'field' => 'check_terms',
     'label' => 'Terms of service',
     'rules' => 'callback_check_terms'
)

A very simple function in my controller below just checks the input and provides a custom error message

Code:
public function check_terms($terms=0){
     if ($terms != 'agree')
     {
          $this->form_validation->set_message('check_terms', 'The terms of service must be read and agreed to before continuing.');
          return FALSE;
     }
     else
     {
          return TRUE;
     }
}

I wanted to make the function above 'private' so it couldn't be accessed by the URI but obviously this prevents the helper from accessing the function. I cant add the underscore to the function name because the callback doesn't seem to accept it. I was thinking of using the _remap function to send 'check_terms' in the uri to the 404 but this seems a little overkill.

Can anyone suggest a more elegant solution?


Messages In This Thread
Private function and Custom form validation - by El Forum - 07-08-2012, 09:23 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:47 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:51 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:52 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:54 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:55 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:57 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 09:58 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 10:02 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 10:03 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 10:03 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 10:08 AM
Private function and Custom form validation - by El Forum - 07-08-2012, 10:17 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.