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

Can't figure out how-to ManyManyFileDataObjectManager


Reply

3 Posts   915 Views

Avatar
dizzystuff

5 April 2010 at 12:26am Community Member, 93 Posts

Hey All

Major brainfreeze I think. Really struggling to implement a ManyManyFileDataObjectManager.

I have a 'ResourcePage' which I would like to have a many-many relationship with a subclass of File, 'ResourceFile'.

ResourcePage has manymany of 'ResourceFiles' => 'ResourceFile' and Resource File has a belongs_many_many of 'ResourcePages' => 'ResourcePage' and the following is how I'm trying to initialise the ManyManyFileDOM.

new ManyManyFileDataObjectManager(
   $this,
   'ResourceFiles',
   'ResourceFile',
   'ResourcePages',
   array(
      'Name' => 'Name'
   ),
   'getCMSFields_forPopup'
);

But TBH the above is me just taking a stab in the dark after many attempts. The error I get when trying to create a ResourcePage in the CMS is:

ERROR [Warning]: Missing argument 3 for FileDataObjectManager_Item::__construct(), called in /path/to/www/sapphire/forms/ComplexTableField.php on line 297 and defined
IN POST /admin/getitem?ID=108&ajax=1
Line 648 in /path/to/www/dataobject_manager/code/FileDataObjectManager.php

Is anyone able to correct the above code, or rather and preferably, show me an example of a working HasMany / ManyManyFileDataObjectManager? Would be most excellent.

Also, I'm currently using 2.4rc1.

Avatar
UncleCheese

5 April 2010 at 2:12am 4085 Posts

First, you can't manage a relationship directly to File objects or subclasses thereof. You need to create a DataObject that contains a file, as shown in the documentation for FileDOM.

Also, around r380 or so, the source code was branched to support 2.4 and 2.3. 2.4 is on the trunk, so make sure you're on the latest rev.

Avatar
dizzystuff

5 April 2010 at 3:06am Community Member, 93 Posts

Hi UncleCheese

Thanks for your reply. I knew there would be some big forehead-slap worthy thing that I had missed. Gosh. I'll give it a whirl in the morning and hopefully all should be fine.

I'm pretty sure I'm on the latest or close-to rev, but will run an update to be sure, thanks.

Cheers
dizzy