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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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



6 Posts   1792 Views


4 October 2010 at 6:49pm Community Member, 41 Posts


I'm trying to figure out a way to provide a UI for editing one of my $many_many_extraFields. I have two classes: CenterPage and TeamMember. They are setup as follows...

class CenterPage extends Page {

static $belongs_many_many = array(
'TeamMembers' => 'TeamMember',


TeamMember extends Page {

static $many_many = array(
'Centers' => 'CenterPage',
static $many_many_extraFields = array(
'Centers' => array(
'Type' => "Enum('Teacher, Supervisor, Director', 'Teacher')",

function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Centers', $centers = new ManyManyDataObjectManager(
'Title' => 'Title',
'Type' => 'Type'
return $fields;

So it would be great to have a dropdown to select the TeamMember Type. The first thing that came to mind was using a Custom DOM Action (popup) with a dropdownfield. I'm having a tough time wrapping my head around implementing it. Any help would be appreciated.


13 October 2010 at 10:46am Community Member, 8 Posts

Hey Gene, did you have any luck with this?


13 October 2010 at 10:58am Community Member, 41 Posts

Yeah I did, but I definitely went for the fastest solution over the cleanest.

What I did was return a dropdown with the choices for the extra field in one of the columns in the DOM. Then I just included some javascript that attached to the 'change' event of the dropdown and made an ajax call to save the changes. The main downside being that you had to make sure the record was selected and saved first before you could edit the many_many_extraFields column. Other than that it works fine for now. When I have some time I might properly subclass the DOM.

Let me know if you want to see any code.


13 October 2010 at 1:57pm 4085 Posts

The way you do it is to pass the DOM to your getCMSFields() function..

public function getCMSFields($dom) {
$parent_page_id = $dom->controller->ID

And then you can run a query based on that ID and set the values of your form fields as needed.

Then, in your onAfterWrite() method, you can inspect the request and update the many_many join table as needed. It's a little kludgy, but not impossible.

Silverstripe tips, tutorials, screencasts, and more.


19 October 2010 at 12:03pm Community Member, 41 Posts

Perfect, thanks for pointing me in the right direction. That's definitely a less kludgy than what I was doing before.


12 March 2011 at 3:48am Community Member, 245 Posts

Hey there Gene,

I've got a similar issue. I need a description field for each many-many relationship I've created, and a way to edit them.

I’ve got is a DataObject called a BusinessNeed. A BusinessNeed just has a Name, really. There are about 15 of these.

On the other side of things I’ve got page type called a ProductPage. This has Content, links, a file download, etc. There are about 5 of these, but more could be added. A ProductPage can be associated with any number of BusinessNeeds, and by dint of that, vice versa. This part I know how to do, I just put a tab on the ProductPage page type that shows the many-many list with checkboxes to associate the ProductPage with the different BusinessNeeds and I have my relationship(s). What I don't have is a GUI.

I saw @unclecheese's response, but I'm afraid this whole thread isn't showing me enough. I don't know what it means to "pass the DOM to your getCMSFields() function". Any way you can show me some code??