Welcome Guest, Not a member yet? Register   Sign In
How do you use the validation library (pattern-wise)
#1

[eluser]parrots[/eluser]
I've been using CI since 1.6.x and the change to the validation library in 1.7 is making me rethink how I'm using it. When I started using it I believe I took it a bit beyond what it was intended for -- I used it to power not only validation but aspects of the form. Now since the validation library is only activated if there is post data I need to rework a lot as I convert over to the new library.

For example I previously added a MY_validation library that allowed external access to the rules/titles and also added the ability to set defaults. I generated labels within the HTML based on title string and used the rules to determine if it was a required field and add an asterisk. It also made sure everything about the form was set in the controller.

I liked the idea of having all data for "this is a required field" in the rule, as opposed to having to keep the view (where I'd now have to programatically put in the required denotation) and the rules in sync leaving more room for errors.

I'm interested in seeing what pattern other people follow when generating forms -- from drawing them to validating the input. Do you pass in one big array of defaults to the view, do you use the language library and use a lookup to that for both the title and the label within the view, do you manually keep rules and the view in sync, etc?




Theme © iAndrew 2016 - Forum software by © MyBB