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

"Cannot instantiate abstract class Object" when using ManyManyDataObjectManager


Go to End
Reply


3 Posts   2599 Views

Avatar
PapaBear

Community Member, 26 Posts

2 July 2010 at 12:15pm

Hi All,

I'm forking the Calendar_Event module to produce a SportsEvent calendar with custom searching.

I've added a Sport DataObject with the following code:

class Sport extends DataObject {
	static $db = array (
		"Name" => "Text"
	);

	static $has_one = array ();

	static $belongs_many_many = array (
		"Events" => "CalendarEvent"
	);

	static $summary_fields = array (
		"Name"
	);

	public function getCMSFields_forPopup(){
		$fields = new FieldSet ();
		$fields->push ( new TextField ( 'Name', 'Sport Name' ));
		return $fields;
	}
}

and I've updated the settings in CalendarEvent as follows:

	static $many_many = array (
		'RecurringDaysOfWeek' => 'RecurringDayOfWeek',
		'RecurringDaysOfMonth' => 'RecurringDayOfMonth',
		"Sports" => "Sport"
	);

My MMDOM code is:

		$sportsTable = new ManyManyDataObjectManager (
			$this,
			"Event Sports",
			"Sport",
			array (
				"Name" => "Sport Name"
			),
			"getCMSFields_forPopup"
		);
		$sportsTable->setParentClass("CalendarEvent");
		$sportsTable->setAddTitle ("a Sport");
		$f->addFieldToTab ( "Root.Content.Sports", $sportsTable );

But I'm getting the error "Fatal error: Cannot instantiate abstract class Object in /home/www/sportspost/sportspost.co.nz/sapphire/core/Object.php on line 115" whenever I try to use the CMS. I've narrowed it down to the MMDOM call but I can't seems to work out where I am going wrong in my code.

Can anyone help?

Cheers
James.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

2 July 2010 at 12:40pm

This is incorrect:

$sportsTable = new ManyManyDataObjectManager (
$this,
"Event Sports",
"Sport",
array (
"Name" => "Sport Name"
),
"getCMSFields_forPopup"
);

Check your second and third arguments.

Avatar
PapaBear

Community Member, 26 Posts

2 July 2010 at 12:52pm

Thank you! Couldn't see the wood for the trees. Changed the second argument to "Sports" and all is serene!