Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » A DataObject as part of another DataObject

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

Page: 1
Go to End
Author Topic: 367 Views
  • soolan
    Avatar
    Community Member
    11 Posts

    A DataObject as part of another DataObject Link to this post

    Hello,

    Imagine that you have a DataObject called Product with some data defined for it:

    class Product extends DataObject {
       //db fields
       static $db = array(
    'Name'       => 'Varchar',
    'Description'    => 'Text',
          //'etc
    );

    I need to define a set of Features for each Products:

    class Feature extends DataObject {
       //db fields
       static $db = array(
    'f1'    => 'Varchar',
    'f2'    => 'Text',
          //'etc
    );

    Assuming Features can not be created before creating a Product itself,
    how can I create a Product and its Features, inside the Products popup (i.e. assign the Main tab for product fields and create a new tab for Features).

    Thank you very much.

  • frankmullenger
    Avatar
    Forum Moderator
    51 Posts

    Re: A DataObject as part of another DataObject Link to this post

    Not sure if you have the option but I think using SilverStripe 3 takes care of this case for you by default. Certainly it is easy in 3 to add a tab to the getCMSFields() function if the record exists - so a tab for managing features would not appear first time you create the Product DataObject.

  • soolan
    Avatar
    Community Member
    11 Posts

    Re: A DataObject as part of another DataObject Link to this post

    Thanks Frank,
    Unfortunately I couldn't find that feature.
    So I added the second DataObject as part of the first one.
    Not a good solution but it works for now.

    I'd really like to use DataObjectmanager module in SS3, but I failed.
    Too many deprecated methods and settings...

    But thanks anyway.

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