1
votes

I have a class ProductPage extends Page and a class ProductSpecifications extends DataObject. Can I create a $has_one relationship to the Dataobject and a $belongs_to back to the ProductPage? (I know it's easier just to keep all the data associated to the page but I would prefer the ProductSpecifications as a separate dataobject). If so how do I access the CMSfields of the Dataobject from the Page? Gridfield? Or something like

$fieldsToAdd = ProductSpecifications::create();
$fieldsToAdd->getCMSFields();
$fields->addFieldsToTab('Root.Specifications', $fieldsToAdd);
1

1 Answers

1
votes

You're speaking of a 1:1 relation? Then the heading of the question is a bit misleading.

You can edit a has_one "inline" using the has one edit module

hope that helps, wmk