7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » ImageDataObjectManager in a DataObjectDecorator
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 947 Views |
-
ImageDataObjectManager in a DataObjectDecorator

1 May 2010 at 6:36am
I've added an "image gallery" of sorts to a DataObject on my site and I'm trying to use ImageDataObjectManager to manage the images for each DataObject... my code looks like:
class MyObjectExtraFields extends DataObjectDecorator {
public function extraStatics() {
return array(
'has_many' => array('GalleryImages' => 'MyObjectGalleryImage')
);
}public function updateCMSFields(FieldSet &$fields) {
$fields->addFieldToTab('Root.GalleryImages', new ImageDataObjectManager($this->owner, 'GalleryImages', 'MyObjectGalleryImage', 'Image', array(), 'getCMSFields_forPopup'));
}
}class MyObjectGalleryImage extends DataObject {
static $db = array('Caption'=>'Varchar(255)', 'Description' => 'HTMLText');
static $has_one = array('ParentMyObject' => 'MyObject', 'Image' => 'Image');
public function getCMSFields_forPopup() { ... }
}The problem I'm running into is that whenever I create a new MyObject in the admin the "Gallery Images" tab shows all of the MyObjectGalleryImages that I've added to other MyObjects, and if I delete them it removes them from every MyObject. Am I not linking something together correctly?
-
Re: ImageDataObjectManager in a DataObjectDecorator

1 May 2010 at 6:45am Last edited: 1 May 2010 6:46am
You're going to need to use setParentClass("ClassYoureDecorating") on your DOM because it won't be able to automatically assign the parent class from within a decorator.
| 947 Views | ||
|
Page:
1
|
Go to Top |

