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.

Data Model Questions /

A DataObject as part of another DataObject


Reply


3 Posts   433 Views

Avatar
soolan

Community Member, 11 Posts

4 March 2013 at 7:24pm

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.

Avatar
frankmullenger

Forum Moderator, 53 Posts

5 March 2013 at 11:53am

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.

Avatar
soolan

Community Member, 11 Posts

11 March 2013 at 12:31pm

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.