FIX: No need to write record before relation is set - it may fail validation where the file is required

This commit is contained in:
Tony Air 2022-04-19 15:18:36 +02:00 committed by GitHub
parent f9437870a3
commit 8341a46aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -82,10 +82,9 @@ class BulkUploadHandler extends RequestHandler
$record = $recordClass::create();
$record->extend('onBulkUpload', $this->gridField);
$record->write();
$fileRelationName = $this->component->getFileRelationName($this->gridField);
$record->{"{$fileRelationName}ID"} = $fileID;
$record->write(); //HasManyList call write on record but not ManyManyList, so we call it here again
$this->gridField->list->add($record);