Data validation and processing. In controller or model? Getting error back to controller. Exceptions?

#3
[eluser]batfastad[/eluser]
Yeah to me I think it makes more sense to do form validation in the controller. Depending on the result of that validation you might not want to load/access the model.
E.g. if you have a form that POSTs to itself then you'll want to check if $this->input->post() is true or false to either process the form input or display your HTML form.

Also I can't foresee a situation where a query (in the project that prompted this question at least) will need to be performed by forms from different pages. That's the benefit I can see of doing form validation in the model... if you'll need to re-use a complete model method elsewhere.

For any post-processing of data, it definitely makes sense to do at the last possible moment before it goes into the DB though. I'm already doing that in the model.

It looks like something that seems to be down to personal preference, without any real recommendations, and that's a good thing as I can do it the way it makes sense to me.


Messages In This Thread
Data validation and processing. In controller or model? Getting error back to controller. Exceptions? - by El Forum - 10-29-2012, 05:15 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.