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?