Silverstripe Version: 4.4.4
**Question: Uploading photos does not always work using bulkUploader. **
Hello,
I have the following problem:
I have a page with an image gallery and I’m utilising BulkUploader as means to upload several photos. On my page I have the bulk upload filedrop area - the one with “Browse or Add from files” buttons. I normally have to upload photos through the popup window that shows up when I click “Add from files” .
I noticed that whenever I choose a photo and click “Insert” a POST request is made to “admin/assets/schema/fileSelectForm/{page_id}” but no errors are returned. This happens randomly and not always and I don’t really know how to approach this problem
Here’s the code I have:
GalleryPage.php
// use ....
class GalleryPage extends Page{
private static $many_many = [
"GalleryItems" => "GalleryItem"
];
private static $many_many_extraFields = [
"GalleryItems" => ["SortOrder" => "Int"]
];
private static $owns = ["GalleryItems"];
public function getCMSFields(){
$fields = parent::getCMSFields();
$config = GridFieldConfig_RelationEditor::create();
$config->addComponent($sortable = new GridFieldSortableRows("SortOrder"));
$sortable->setUpdateVersionedStage('Live');
$config->addComponent(new BulkUploader(null, null, true));
$config->getComponentByType('Colymba\BulkUpload\BulkUploader')
->setUfSetup('setFolderName', '/');
$config->getComponentByType('SilverStripe\Forms\GridField\GridFieldPaginator')->setItemsPerPage(100);
$config->removeComponentsByType(SilverStripe\Forms\GridField\GridFieldAddNewButton::class);
$config->removeComponentsByType(SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter::class);
$gridField = new GridField("GalleryItems", "GalleryItems", $this->GalleryItems(), $config);
$fields->addFieldToTab("Root.Images", $gridField);
return $fields;
}
}
and
GalleryItem.php
// use ...
class GalleryItem extends DataObject{
private static $db = ["Description" => "Varchar(255)"];
private static $has_one = [
"Image" => Image::class,
"Page" => "GalleryPage"
];
private static $owns = [
"Image"
];
public function onAfterWrite() {
parent::onAfterWrite();
if ($this->Image()->exists() && !$this->Image()->isPublished()) {
$this->Image()->doPublish();
}
}
private static $summary_fields = ["Thumbnail", "Description"];
public function getThumbnail() {...}
}
I hope I described the problem properly
Thank you in advance!