Welcome Guest, Not a member yet? Register   Sign In
Form validation by my own method
#6

(04-28-2015, 04:12 AM)Valery Wrote: Hello, RogerMore!

Thank you for aswer. But callback function doesn't suit me - I'd like to use this function not only in this controller. But this form ($this->input->post("password")) is what I was looking for. Thank you!

If you don't mind, I have one more question. If I am using callback function, I have to declare it such:

PHP Code:
public function my_callback_function($str)
{
 
  ...

And there is an opportunity to call this function via URL, for example: http://www.mysite.com/my_controller/my_c...nction/aaa

How can I hide such functions? I've tried "protected" and "private", but it doesn't work.

Thank you.

If you create a public function with an underscore as the first character of the function name, CI won't route that function to a URL, but it will still be visible to the form_validation class. So, you would define the method like this:
Code:
public function _my_callback_function($str)

Then you would set your validation rule as:
Code:
callback__my_callback_function

(Note the double underscore after the first instance of the word 'callback'.)
Reply


Messages In This Thread
Form validation by my own method - by Valery - 04-25-2015, 09:07 AM
RE: Form validation by my own method - by Valery - 04-28-2015, 04:20 AM
RE: Form validation by my own method - by Valery - 04-28-2015, 04:12 AM
RE: Form validation by my own method - by mwhitney - 04-28-2015, 10:19 AM
RE: Form validation by my own method - by CroNiX - 04-28-2015, 11:33 AM
RE: Form validation by my own method - by Valery - 04-29-2015, 07:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB