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

ManyManyDataObjectManager throws Error


Go to End
Reply


685 Views

Avatar
michito

Community Member, 4 Posts

28 June 2012 at 2:19am

Edited: 28/06/2012 2:20am

Hi everyone,

sorry to bother, but I can't figure out what the problem is here. Basically I want to connect one DataObject (Event) to several other ones (Info). Seems to be a pretty basic failure by me, but I don't get it. It works with $has_one and HasOneDataObjectManager but that way I can only connect one DataObject to another…

BTW: HasManyDataObjectManager doesn't work either. And yes, I did ?flush=1 :)

Here ist my code, help is very appreciated.

Event.php

class Event extends DataObject
{
        static $db = array (
                 ...
	);
	
	static $has_one = array (
		'Events' => 'EventsPage',
	);
	
	static $has_many = array (
		'Infos' => 'Info'
	);
	
	public static $singular_name = "Event";
	public static $plural_name = "Events";
	
	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			...
			new ManyManyDataObjectManager($this, 'Infos', 'Info', array('Title' => 'Titel'), 'getCMSFields')
		);
	}
}

Info.php

class Info extends DataObject
{
    static $db = array (
		...
	);
	
	static $has_one = array (
		'Info' => 'Eventspage',
		'Bild' => 'Image'
	);
	
	static $belongs_many_many = array (
		'Events' => 'Event'
	);
	
	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			...
		);
	}
}

The Error I'm getting is:

[Warning] Missing argument 1 for DataObject::get(), called in .../SilverStripe/sapphire/core/ViewableData.php on line 112 and defined
GET .../SilverStripe/admin/EditForm/field/Events/item/1/edit?SecurityID=14e29ad56b1e0e948f1ed3189c4727c143a3737e&ctf[Events][start]=0&ctf[Events][per_page]=10&ctf[Events][showall]=0&ctf[Events][sort]=StartDate&ctf[Events][sort_dir]=DESC&ctf[Events][search]=&ctf[Events][filter]=

Line 2713 in .../SilverStripe/sapphire/core/model/DataObject.php

Thanks in advance.