Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Custom HasManyComplexTableField/HasManyDataObjectManager with join -- adding new items

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

Page: 1
Go to End
Author Topic: 1661 Views
  • jackson_gabbard
    Community Member
    13 Posts

    Custom HasManyComplexTableField/HasManyDataObjectManager with join -- adding new items Link to this post

    So, I'm trying to use a HasManyDataObjectManager for its sweet sorting capabilities. Since I'm not using the DOM globally, I just want to replace the HasManyComplexTableField in the model admin for a particular dataobject.

    The overal picture of my situation is this--

    MovieSet DataObject has_many Movies

    Movie has_one MovieSet, has_one File and is sortable

    The idea here is that a single file can belong to multiple movie sets and be sorted uniquely in the set.

    So far so good. The problem comes once I replace the HasManyComplexTableField for the Movies of the MovieSet. In order to only show the Movies that belong to the MovieSet, I'm setting a Filter for the HasManyDataObjectManager that limits the Movie objects that appear in the grid to only ones that have a MovieSetID that matches the current movie sets. That works like a champ, too.

    Next, I test the functionality of the form--I can click Add Movie to launch the pop-up form for adding a movie. I can save this movie successfully, but I hit the problem. Because the movie created isn't automatically associated with the MovieSet under which it was created, when the grid refreshes the newly created Movie isn't included in the list (i.e. it's has_one of MovieSet isn't populated with the current MovieSet, in fact it's empty).

    Anyone have an idea of how to do this? I'm guessing the HasManyComplexTableField solves this problem by prepopulating the MovieSetID field with the ID of the currently-open MovieSet when it launches the popup form, but I haven't dug into it yet.

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.