Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Nested relationships

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

Page: 1
Go to End
Author Topic: 1072 Views
  • AdamJ
    Avatar
    Community Member
    145 Posts

    Nested relationships Link to this post

    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

  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: Nested relationships Link to this post

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

    Cheers

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Nested relationships Link to this post

    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().

  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: Nested relationships Link to this post

    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

    1072 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.