Welcome Guest, Not a member yet? Register   Sign In
Structural Design Question - The Validation case.
#1

[eluser]MEM[/eluser]
Hello all,

I've followed this example:
http://ellislab.com/codeigniter/user-gui...ation.html

However, a question remains: What should we do, if we want to validate, not only users on insertion but, also, Associations on Update, and other things, like contacts forms?

Should we create a new form controller for each form we want to validate?

Isn't possible to use one form controller with rules for all possible forms on the site?
If so, how can we deal with the views on this scenario?


Any help will be greatly appreciated,
Márcio
#2

[eluser]Jondolar[/eluser]
It makes sense to me that you create a method(function) for each form. You can have one controller but each form posts to a different function within that controller.
#3

[eluser]MEM[/eluser]
Thanks a lot. I do now ask: Does my question makes any sense, or I'm just not thinking the "CI Validation Logic" properly ? If so, please, let me know.
If not, I will then gladly follow the solution provided, to allow validation rules for all forms on my website.


Regards,
Márcio
#4

[eluser]skunkbad[/eluser]
In my case, the validation is almost always done in the same controller that loaded the form. They share a form validation callbacks model. The validation itself does not take many lines to accomplish, but I found myself needing various callbacks in multiple controllers, so I put them in a model. Search the forum for a MY_Form_validation class that extends Form_validation. It allows for the callbacks to be placed outside the controller.
#5

[eluser]MEM[/eluser]
Thanks a lot. I'm absolutly newbie on several subjects here, I will try to learn about callbacks, what they are, and why do we need them, and try to grasp your tip. Smile

Regards,
Márcio




Theme © iAndrew 2016 - Forum software by © MyBB