Silverstripe Version: 4.4
Question:
I have a many-to-many relationship between Page
and Image
, with additional fields on the link table (as part of a sorting module).
When I upload images, I get the usual thumbnail and details, with the “DRAFT” label, as expected. However, I also have the image focus add-on enabled to help with cropping, so I would like to edit the file at the time of the upload.
This is my upload field:
But if I click on the View
button, all the fields are disabled so I can’t change any of them, not even after saving the page (and in turn, publishing the image).
If I go to the file manager, I can edit it fine. But is there a way to edit this here at the time of uploading? I’m sure I could do this elsewhere, so not sure if the relationship (many-to-many) is causing an issue?
Any help appreciated, as always!
Just for reference:
Page.php
private static $has_one = [
'HeaderImage' => Image::class
];
private static $many_many = [
'Slides' => Image::class
];
private static $owns = [
'Slides'
];
// this adds the SortOrder field to the relation table.
// Please note that the key (in this case 'Slides')
// has to be the same key as in the $many_many definition!
private static $many_many_extraFields = [
'Slides' => ['SortOrder' => 'Int']
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
// Slides
$fields->addFieldToTab('Root.Header', SortableUploadField::create('Slides', 'Slides'));
return $fields;
}
mysite.yml
---
Name: myproject
---
SilverStripe\Core\Manifest\ModuleManifest:
project: app
SilverStripe\Assets\Image:
belongs_many_many:
Pages: Page.Slides