Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » "Cannot instantiate abstract class Object" when using ManyManyDataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 2144 Views
  • PapaBear
    Avatar
    Community Member
    26 Posts

    "Cannot instantiate abstract class Object" when using ManyManyDataObjectManager Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: "Cannot instantiate abstract class Object" when using ManyManyDataObjectManager Link to this post

    This is incorrect:

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

    Check your second and third arguments.

  • PapaBear
    Avatar
    Community Member
    26 Posts

    Re: "Cannot instantiate abstract class Object" when using ManyManyDataObjectManager Link to this post

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

    2144 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.