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.

Data Model Questions

Nested relationships


4 Posts   1100 Views


12 May 2009 at 6:12pm Community Member, 145 Posts

Hey guys,

I'm currently working on a side project for a friend who runs a training program. I'm trying to intergrate his workshops into Silverstripe so he can easily update them, and I can do some funky stuff on the website to display them (planning to intergrate google maps - fingers crossed).

This is the relationships I have.

They have Workshops.
Each Workshop has many Dates.
Each Date has one Location and many Instructors.
(Locations and Instructors belong to many Dates)

How would I achieve this in the CMS? I have gone through tutorial 5, and can understand how to relate Dates to Workshops, and add a tab to add/edit/remove dates, but how do I then select/add/edit/remove a Location and Instructors to each Date?

Thanks in advance


21 May 2009 at 12:27am Community Member, 145 Posts

Sorry to bump up my own thread, but I was wondering if anyone had any words of wisdom for me on this one.



22 May 2009 at 1:21pm Forum Moderator, 5511 Posts

The hard thing here is you cannot nest complextablefields. So I you will have trouble managing Instructors as its on 2 branches of a has many.

I think one way you could do it is like:

- Workshop is a page
- Dates is a HasManyComplexTableField on that page
- Inside the Date Popup you have a CheckboxSetField of all the Instructors (which you can then select many) and a dropdown for the location.

Then you would just need to generate a way of adding / editing instructors and locations. The easy way to do this would be to just add a TableListField to the WorkshopPage which allows you to manage them. Its a bit nasty.

Or you could try using ModelAdmin to manage the data - In that case you would have 2 managed models - Instructions, Locations and you would keep the HasManyComplexTableField().


22 May 2009 at 1:31pm Community Member, 145 Posts

Cheers for the reply willr.

I'm going to setup Instructors as a page, so the adding of Instructors could be handled that way. I may have to move the Location information as part of Dates to simply the workflow.

Thanks again