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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Where to put CRUD operations in MVC world


Go to End


2 Posts   1722 Views

Avatar
neros3

Community Member, 51 Posts

3 September 2010 at 6:40pm

Edited: 03/09/2010 7:22pm

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

Forum Moderator, 5523 Posts

3 September 2010 at 7:17pm

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