Welcome Guest, Not a member yet? Register   Sign In
Validation: Using callbacks from a model
#21

[eluser]TheFuzzy0ne[/eluser]
It can work in libraries. You simply pass the library through as the "$parent" parameter, and the form_validation class will take it by reference. It will then look in that library/object for the validation rule.

EDIT: That is for the form_validation extension class from the wiki.
#22

[eluser]Colin Williams[/eluser]
Quote:It does feel a bit “wrong” to place validation rules in Models, but it’s way better than repeating a bunch of callback functions in every controller.

I guess it really depends on the nature of the callback. For instance, I don't think the validation class has an is_valid_phone_number rule. But if you are going to add such a generic rule, then I think it makes sense to belong with the other rule checks like valid_email, etc. Meaning, extend the Form_validation class and add those methods.




Theme © iAndrew 2016 - Forum software by © MyBB