4

I need to check if the user_id that was inserted exists. I was going to use callbacks in Codeigniter form validation but they require the function that does the validation be in the controller. I'm using this on many pages across multiple controllers so I thought I would do it in a model. Codeigniter doesnt support this though.

http://codeigniter.com/forums/viewthread/205469/

I found this but it seems like a lot of code per validation. I'm using this alot so I dont want that big glob of code every time.

How can I run a form validation from a model with as little code as possible?

4
  • What exactly is your question? Commented Jun 13, 2012 at 17:39
  • @Colin how to call a external callback method Commented Jun 13, 2012 at 17:41
  • have you tried anything? Commented Jun 13, 2012 at 17:44
  • codeigniter.com/forums/viewthread/123780 but its outdated Commented Jun 13, 2012 at 17:45

1 Answer 1

6

Extend CI_Form_Validation. That way you will be able to call your callbacks just like all the other Codeigniter validation functions.

Sign up to request clarification or add additional context in comments.

7 Comments

Are you saying make a MY_Form_Validation ?
This might sound dumb but where would that file go? And would i just have the function that does the validation? or would i need the $config stuff too?
Inside application/core. Read here: codeigniter.com/user_guide/general/core_classes.html
Wouldn't the file go in application/libraries ?
No. That was the directory in CI 1.7.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.