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, Ed, biapar, Willr, Ingo, swaiba

Multiple has_many relationships for the same class

Go to End

3 Posts   1554 Views


Community Member, 41 Posts

19 October 2010 at 12:06pm

Does the DOM support the new has_many class.field syntax in 2.4? (

I have been unable to get it to work properly.


Forum Moderator, 4102 Posts

19 October 2010 at 1:18pm

I wasn't aware that was ready yet. That's good to see.

I'm not sure there's anything to update, though. I think all of that is handled further upstream in the DataObject class. Can you give it a try and let me know how it goes?

Silverstripe tips, tutorials, screencasts, and more.


Community Member, 41 Posts

19 October 2010 at 1:26pm

I couldn't get it working. Here's what I have...

static $has_many = array(
		'PackagePromos' => 'Promo.Package',
		'FlightsPromos' => 'Promo.Flights',
		'BookingPromos' => 'Promo.Booking',

function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Content.Package', new HasManyDataObjectManager(
//... other hasmanydoms

This throws an error on save.

I also tried replacing 'Promo' in the HasManyDom with 'Promo.Package' which seems more correct but the DOM throws an error in the constructor 'Bad Class to Singleton' - line 96. I think it needs to be split at the period at that location in order to create the class properly.