Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Different DOM's for subtypes of type

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: 685 Views
  • omarkohl
    Avatar
    Community Member
    30 Posts

    Different DOM's for subtypes of type Link to this post

    I have a class Foo (extending DataObject). A certain page type has_many Foo. I don't actually use objects of type Foo but only subtypes (inherited classes) RedFoo, BlueFoo and GreenFoo.

    I want to have a DOM for each of these inherited Foo's ( DOM(RedFoo), DOM(BlueFoo), DOM(GreenFoo) ) but I don't want to have 3 has_many relations in the page. Is this possible?

    I know you can pass a $sourceFilter to the constructor of the DOM so I could filter the specific Foo type I want for each DOM, but the DOM wouldn't be aware of what kind of Foo's he's managing. And it is important that each DOM know what kind of Foo he uses because they have different fields (e.g. one has an image field, another a text field).

    The reason to have it this way is because in the frontend I want to treat all Foo's the same (with specific display mechanisms).

  • misterac
    Avatar
    Community Member
    7 Posts

    Re: Different DOM's for subtypes of type Link to this post

    I'm interested in something similar to this. I'd like the DOM to allow me to create objects that are sub types of Foo. In other words:

    Page has_many Foo

    Bar extends Foo
    Baz extends Foo

    DOM should allow the creation of Bar and Baz objects for the has_many relation.

    Is such a thing possible?

  • omarkohl
    Avatar
    Community Member
    30 Posts

    Re: Different DOM's for subtypes of type Link to this post

    I had to create 3 differente DOM's and 3 has_many relations. Maybe I just didn't find the solution but to me it looks like it is not possible.

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