In Silverstripe 4 a file that is uploaded must be published before it is visible to the public side of the site.
If I create a $Page with a $has_one Image::Class and then also assign that image to $owns[] the uploaded image will be published when I publish the page.
However If I create the following data object structure it will not.
Class Item extends DataObject{
$has_one[
'ItemImage'=>Image::Class,
'Catalog'=>'Catalog'
];
$owns[
'ItemImage'
]
}
Class Catalog extend DataObject{
$has_many[
'Items'=>'Item'
]
$owns[
'Items'
]
public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Items', GridField::create('Items', 'Items', $this->Items(), GridFieldConfig_RecordEditor::create()));
return $fields;
}
}
If I create a catalog and within it create items with images and then save it, it will not publish the images that were uploaded. I will have to manually: 1. Select the image 2. Edit Original 3. Publish
There has to be an easier way for the user.