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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Bug while calling the ManyManyDataObjectManager


Go to End


9 Posts   3939 Views

Avatar
brokemeister

Community Member, 30 Posts

12 June 2009 at 11:34pm

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

13 June 2009 at 1:24am

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

Avatar
brokemeister

Community Member, 30 Posts

13 June 2009 at 2:22am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

13 June 2009 at 3:16am

Yeah, you've set up your model wrong.

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

ManyManyDOM

$this,
'NameOfDataObjects',
'DataObjectClassName'

Avatar
brokemeister

Community Member, 30 Posts

13 June 2009 at 7:23pm

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 June 2009 at 9:43am

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.

Avatar
brokemeister

Community Member, 30 Posts

17 June 2009 at 9:35pm

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 June 2009 at 1:46am

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!

Go to Top