Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Bug while calling the ManyManyDataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 1895 Views
  • brokemeister
    Avatar
    Community Member
    30 Posts

    Bug while calling the ManyManyDataObjectManager Link to this post

    I Just wanted to display a ManyMany-Relation with the ManyManyDataObjectManager.

    But I always get following error:
    Fatal error: Access to undeclared static property: ViewableData::$many_many in ~\sapphire\core\Object.php(376) : eval()'d code on line 1

    My DataObject looks like this:
    class ContentDataObject extends DataObject {
       
       static $db = array (
          "Title" => "Varchar(255)",
          //...
       );
       

       static $many_many = array (
          "Connections" => "ArticleDataObject",
       );
       
          
       static $belongs_many_many = array (
          "ConnectionsBelongs" => "ContentDataObject",
       );
    }

    The Manager in the Page looks like this (If I replace "ManyManyDataObjectManager" with "DataObjectManager" is working):
    $manager = new ManyManyDataObjectManager(
             $this,
             'CurrentContent',
             'ContentDataObject',
             $this->getListedFields(),
             'getCMSFields_forPopup'
          );
          return $manager;

    System:
    SS 2.3.1
    dataobject_manager r117

    Any ideas how to solve the error?

    Cheers,

    Malte

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    Looks like you've probably set up your model wrong. Paste in all of your code for the Page object.

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    Hi UncleCheese,

    thanks for your fast reply.
    Here is the PageObject...

    class MagazinDataPage extends DataPage
    {
       static $db = array (
       );
       
       static $has_many = array (
          'Content' => 'ContentDataObject'
       );
       
       static $allowed_children = array("MagazinDataPage");
       
       public function getCMSFields($cms) {
          $fields = parent::getCMSFields($cms);
    //      $fields->addFieldToTab("Root.Content.Current", $this->getCurrentContentManager());
    //      $fields->addFieldToTab("Root.Content.LastChanged", $this->getStoreManager());
    //      $fields->addFieldToTab("Root.Content.Archiv", $this->getZIPManager());
          $fields->addFieldToTab("Root.Content.All", $this->getAllContentManager());
          return $fields;
       }
       
       protected function getAllContentManager() {
          $manager = new ManyManyDataObjectManager(
             $this,
             'CurrentContent',
             'ContentDataObject',
             $this->getListedFields(),
             'getCMSFields_forPopup'/*,
             "MagazinDataPageID = {$this->ID}"*/
          );
    //      $manager->setParentClass('MagazinDataPage');
          $manager->setFilter("ClassName", "ContentType", ContentDataObject::getContentTypeClasses());
          return $manager;
       }
       
       protected function getListedFields() {
          return array(
                "ClassName" => "ContentType",
                "Title" => "Titel",
                "ShowOn" => "Erscheinungsdatum",
                "Disabled" => "Versteckt",
                "HideOn"=> "Ausblendungsdatum"
             );
       }
       
    }

    class MagazinDataPage_Controller extends DataPage_Controller
    {

    }

    Cheers,

    Malte

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    Yeah, you've set up your model wrong.

    Page => $many_many DataObjects
    DataObject => $belongs_many_many Pages

    ManyManyDOM

    $this,
    'NameOfDataObjects',
    'DataObjectClassName'

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    But than my Konzept does not work.

    I would like to have
    Page => $has_many DataObjects
    DataObject => $has_one Page

    DataObject => $many_many DataObjects
    DataObject => $belongs_many_many DataObjects

    So a DataObect is stored in one Page.
    And all DataObjects can be connected to each other.

    How can I solve this? I don't want to have each DataObject as Page or did I get something wrong?

    Cheers,

    Malte

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    If you're relating dataobjects to a dataobject, you need to use a CheckboxSetField in your popup form. The ManyManyDataObjectManager is used for attaching DataObjects to Pages. If those DataObjects have their own sets of relationships, they are handled in the edit window for each of those objects -- not in the MMDOM.

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    Thanks for your help.

    Generally it works, but if you have more than 20 Objects available. It's not managable anymore.
    I have to rework this part of my concept.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug while calling the ManyManyDataObjectManager Link to this post

    You MIGHT have some luck with the MultiSelectField here http://www.silverstripe.org/multiselectfield-module/ which is built for this sort of thing. I'd say there's a 50% chance it will fail in a popup window, though.

    Worth a shot!

    1895 Views
Page: 1 2
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.