23459 Posts in 18906 Topics by 2877 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
30 October 2009 at 9:36am Last edited: 30 October 2009 9:40am
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 set's. 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 fix this/set that field automatically in the pop-up? 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.
30 October 2009 at 10:19am Last edited: 30 October 2009 10:19am
One step closer--setting the relationAutoSetting on the HasManyDataObjectManager gets me part of the way there. By setting it to true, the created Movie will automatically get assigned a MovieSet of the one currently being managed. The only thing this doesn't do then is assign the newly created Movie as checked within the MovieSet has_many relation. Basically, the goal is to be able to create a new Movie and have both the current MovieSet and the Movie created reference eachother automagically.
21 July 2011 at 6:50pm
Anda a freir churros pibe
|Go to Top|