Form Validation Default |
(05-26-2016, 09:49 AM)cartalot Wrote:(05-22-2016, 05:23 PM)albertleao Wrote: I personally disagree with putting form validations in models. Form validations, as stated, are for forms, which is found in a view which is handled by controllers. Database validation in models is fine, but if you are using your models with different apps without a front end, things can get hairy quickly. sure that may work for a small application, but if you work on larger, more complex application where different systems use the same models, the forms might not always be the same. I've run into this issue several times when developing for companies. It was especially common in Ruby and Ruby on rails. Several companies would have all their models as it's own git repository and have that repo work for multiple applications. At that point, tying a model to a form validation was wrong and we did validation on a per model/db field basis. After learning this in Ruby, I implemented this in my CI apps and have had a ton more flexibility. Now my models might be delivering data to users, services, apis... and I don't have to worry about 'forms'. I can handle all that in the controllers. In essence, form validation is exactly what it says, form validation which is directly connected to something displayed to the user in a view or an api. A database validation is connected to the database, so that's where you could do field and table constraints on top of the db schema. Just a different perspective...
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
|
Messages In This Thread |
Form Validation Default - by edoramedia - 05-22-2016, 12:32 AM
RE: Form Validation Default - by skunkbad - 05-22-2016, 12:40 AM
RE: Form Validation Default - by cartalot - 05-22-2016, 12:06 PM
RE: Form Validation Default - by albertleao - 05-22-2016, 05:23 PM
RE: Form Validation Default - by cartalot - 05-26-2016, 09:49 AM
RE: Form Validation Default - by albertleao - 05-26-2016, 04:29 PM
RE: Form Validation Default - by skunkbad - 05-26-2016, 10:48 AM
RE: Form Validation Default - by mwhitney - 05-26-2016, 02:14 PM
RE: Form Validation Default - by PaulD - 05-26-2016, 09:05 PM
|