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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

ImageDocumentManager getElementByID null issue


Reply


1132 Views

Avatar
Shawn Parr

Community Member, 60 Posts

12 September 2009 at 9:14am

Here is some more weirdness. I'm creating a custom page for one of our departments that needs to manage images. So I create a dataobject:

class Slide extends DataObject {
      
      static $has_one = array(
         'Image' => 'Image',
         'SlideshowPage' => 'SlideshowPage'
      );
      
      public function getCMSFields_forPopup() {
      
         return new FieldSet(
            new ImageField('Image')
         );
      
      }
   
   }

And a page to interact with it:

class SlideshowPage extends Page {
   
      static $db = array(
         'Speed' => 'Int'
      );
      
      static $has_many = array(
         'Slides' => 'Slide'
      );
      
      function getCMSFields() {
      
         $f = parent::getCMSFields();
         
         $slidemanager = new ImageDataObjectManager(
            $this,
            'Slides',
            'Slide',
            'Image',
            array(
               'Image' => 'Image',
            ),
            'getCMSFields_forPopup'
         );
         
         $slidemanager->allowUploadFolderSelection();
         $f->addFieldToTab("Root.Content.Slides", $slidemanager);
         $f->addFieldToTab("Root.Content.Slides", new TextField('Speed', 'Slideshow speed in milliseconds'));
         return $f;
      
      }
   
   }

The popup appears and all the elements load properly. I click the button to choose files, and do so. They appear queued up. I click the upload button and get what appears to be a javascript alert that says: "TypeError: document.getElementById(params[name]) is null"

When this happens nothing else occurs, no upload, etc. I don't think it is an issue with SWFUploader as putting it in debug mode doesn't report any errors. Also opening the popup in its own tab and using the firefug console doesn't help either as no JS errors appear.

Were it gets weird is two fold:

1. If I change it to FileDocumentManager it works fine (this is my temporary workaround to get them going)
2. Image Gallery also works fine. When I create an image gallery page I can upload images all day long.

Any ideas?