Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » No ParentIDName in ImageDataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1361 Views
  • Gene
    Avatar
    Community Member
    41 Posts

    No ParentIDName in ImageDataObjectManager Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: No ParentIDName in ImageDataObjectManager Link to this post

    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.

  • Gene
    Avatar
    Community Member
    41 Posts

    Re: No ParentIDName in ImageDataObjectManager Link to this post

    Ahh, thanks That was killing me.

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