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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

A DataObject as part of another DataObject


Go to End


3 Posts   1117 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.