Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Can't figure out how-to ManyManyFileDataObjectManager

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: 894 Views
  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Can't figure out how-to ManyManyFileDataObjectManager Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Can't figure out how-to ManyManyFileDataObjectManager Link to this post

    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.

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: Can't figure out how-to ManyManyFileDataObjectManager Link to this post

    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

    894 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.