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

No ParentIDName in ImageDataObjectManager


Go to End


3 Posts   1880 Views

Avatar
Gene

Community Member, 41 Posts

9 September 2009 at 4:52pm

I've narrowed my problem down to not getting a ParentIDName when using the ImageDataObjectManager and it's causing my upload to fail (actually, the files are uploaded and save in the Files table, they're just not associated with the page). Here's my debug info:

SWF DEBUG: Build Number: SWFUPLOAD 2.2.0 Alpha 2008-10-17
SWF DEBUG: movieName: SWFUpload_0
SWF DEBUG: Upload URL: http://localhost/workspace/foundation/FileDataObjectManager_Controller/handleswfupload
SWF DEBUG: File Types String: *.jpg;*.jpg;
SWF DEBUG: Parsed File Types: jpg,jpg,
SWF DEBUG: File Types Description: (*.jpg;*.jpg;)
SWF DEBUG: File Size Limit: 20971520 bytes
SWF DEBUG: File Upload Limit: 20
SWF DEBUG: File Queue Limit: 20
SWF DEBUG: Post Params:
SWF DEBUG: fileClassName=Image
SWF DEBUG: controllerID=12
SWF DEBUG: fileFieldName=Image
SWF DEBUG: dataObjectClassName=PortfolioImage
SWF DEBUG: OverrideUploadFolder=Uploads
SWF DEBUG: hasDataObject=1
SWF DEBUG: dataObjectFieldName=PortfolioImages
SWF DEBUG: parentIDName=
SWF DEBUG: ----- END SWF DEBUG OUTPUT ----
SWF DEBUG:
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.jpg;*.jpg;
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: fileClassName=Image
SWF DEBUG: Global Post Item: controllerID=12
SWF DEBUG: Global Post Item: fileFieldName=Image
SWF DEBUG: Global Post Item: dataObjectClassName=PortfolioImage
SWF DEBUG: Global Post Item: OverrideUploadFolder=Uploads
SWF DEBUG: Global Post Item: hasDataObject=1
SWF DEBUG: Global Post Item: dataObjectFieldName=PortfolioImages
SWF DEBUG: Global Post Item: parentIDName=
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to http://localhost/workspace/foundation/FileDataObjectManager_Controller/handleswfupload for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 145611. Total: 145611
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 500.
SWF DEBUG: Event: uploadComplete : Upload cycle complete.
Error Code: -200, File name: iStock_000007957458XSmall.jpg, File size: 145611, Message: 500

and my code...

class PortfolioItem extends Page {
//...
static $has_many = array(
'PortfolioImages' => 'PortfolioImage',
);

public function getCMSFields() {
$fields = parent::getCMSFields();
//...
$fields->addFieldToTab('Root.Content.Images', new ImageDataObjectManager(
$this,
'PortfolioImages',
'PortfolioImage',
'Image',
array(),
'getCMSFields_forPopup'
));

return $fields;
}
}

class PortfolioImage extends DataObject {

static $has_one = array(
'Image' => 'Image',
);

public function getCMSFields_forPopup() {
return new FieldSet(
new ImageField('Image')
);
}

}

Here's what I'm getting when echoing out a few things in FileDataObjectManager's UploadForm method:

echo $this->getParentClass();
PortfolioItem
echo $this->sourceClass();
PortfolioImage
echo $this->getParentIdName( $this->getParentClass(), $this->sourceClass() );
Nothing

Any help would be appreciated. Thanks.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 September 2009 at 12:20am

You set up your model wrong.

static $has_one = array(
'PortfolioItem' => 'PortfolioItem',
'Image' => 'Image',
);

Don't forget to reciprocate your has_many with a has_one. It's the has_one that counts.

Avatar
Gene

Community Member, 41 Posts

10 September 2009 at 4:49am

Ahh, thanks :) That was killing me.