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

Inherited pages -- sub-class does not save the right Page ID


Go to End


7 Posts   1304 Views

Avatar
dynamite

Community Member, 66 Posts

13 November 2009 at 6:22pm

I know this has been discussed before, but cannot find it for the life of me!

I have ImageDataObjectManager working on Pages but the "PageID" does not get set when upload a new image in the sub-class pages.

Any help would be great!

Jeremy

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 November 2009 at 3:04am

You have to use setParentClass("ParentClass");

The problem is that the DOM gets passed $this as the controller, so on subclasses, it gets passed an object that does not have the foreign key, so you need to be explicit. Same is true for CTFs.

Avatar
dynamite

Community Member, 66 Posts

14 November 2009 at 3:08am

Thank you! I knew what the problem was, just couldn't find the function name.

Avatar
dynamite

Community Member, 66 Posts

16 November 2009 at 6:04pm

I am having a difficult time getting this to work -- I assume that this command should be run in the "getCMSFields" method. What I am missing?

Here is a sample of what I have in code/Page.php:

function getCMSFields()
{
  $fields = parent::getCMSFields();
	
  $manager = new ImageDataObjectManager(
  ....
  $manager->setParentClass('Page');

  $fields->addFieldToTab("Root.Content.FeaturedPhotos", $manager);
		
  return $fields;
}

Thank you!

Jeremy

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 November 2009 at 6:17pm

That looks right to me. What's not working?

Avatar
dynamite

Community Member, 66 Posts

17 November 2009 at 1:55am

Dang, I feel so stupid. I was using an old(er) version of DOM.

But I do have a little problem now - when clicking "Add New ...." or when clicking to edit an existing image, the pop-up doesn't open. Instead the form takes over the whole page.

I tried it 325 and 323 with the same results, and on Firefox and Safari. There were no JS errors in the Firefox Error Console.

What am I doing wrong now? :-)

Jeremy

Avatar
UncleCheese

Forum Moderator, 4102 Posts

17 November 2009 at 2:07am

Some kind of javascript error. I would check Firebug. Make sure the directory for the module is named "dataobject_manager" and not "dataobject_manager_r123" or whatever Silverstripe names it. That path has to be correct to get the JS assets.