Hello,
I have a DataExtension with a has_many
class ProductDetailExtension extends DataExtension {
private static $has_many = array(
'FeatureDetails' => 'FeatureDetail'
);
which I want to apply to different DataObjects and Pages
Product:
extensions:
- ProductDetailExtension
ServicePage:
extensions:
- ProductDetailExtension
Now I have to put the has_one in FeatureDetail which corresponds to the has_many in the ProductDetailExtension
class FeatureDetail extends DataObject {
private static $db = array(
);
private static $has_one = array(
'Feature' => 'Feature',
'ProductService' => '<ProductDetailExtension>'
);
Am I right that there is really no simple built-in way to do this?
Thinking about it (and looking into the comments Addon) I see one complicated way:
Defining FeatureDetail in this way
class FeatureDetail extends DataObject {
private static $db = array(
);
private static $has_one = array(
'Feature' => 'Feature',
'ParentID' => 'Int',
'BaseClass' = 'VarChar'
);
and writing custom methods to save and get FeatureDetails in the extension.
Is this really necessary in SilverStripe?