Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Where to put CRUD operations in MVC world


Reply

2 Posts   1129 Views

Avatar
neros3

3 September 2010 at 6:40pm (Last edited: 3 September 2010 7:22pm), Community Member, 51 Posts

Hi

Im having a little trouble grasping the true MVC concepts. Models should be fat right and controllers skinny and views dumb?
I see the whole Holder concept - a container for multiple pages/objects of same type - But im not sure where to put the CRUD logic. In the holder controller?
The site im working on has several teams with several members. All CRUD is handled by the users in the web frontend and not in the CMS. So to add a new player/member to the team needs an addPlayer action. Would this action be on the TeamHolder or on the Player class? It doesnt make much sense to have an object that adds itself to another page. So since the Teams has players maybe the actions should be handled there?
From the modules I find on the website I think that the Holder classes are also used for CRUD operations.
Could someone perhaps enlighten me?

Thanks!

Avatar
Willr

3 September 2010 at 7:17pm Forum Moderator, 5511 Posts

Well the holder pattern is different to the MVC concept. Since the CRUD operations are normally initialized via the URL then it makes sense to have them tied to the controller class (eg controller/add, controller/delete/2 etc) See the generic views module for an example of CRUD implementation in SilverStripe - http://open.silverstripe.org/browser/modules/genericviews/trunk/code