mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Attach uploaded files directly to parent if exists
If the parent of the file attachment relationship already exists, then attach the file directly to it in this request instead of going through deferred bindings. Will continue to attach files through deferred binding if the parent relation doesn't exist.
This commit is contained in:
parent
f056e8dcb2
commit
422a99770c
@ -394,7 +394,15 @@ class FileUpload extends FormWidgetBase
|
||||
$file->is_public = $fileRelation->isPublic();
|
||||
$file->save();
|
||||
|
||||
$fileRelation->add($file, $this->sessionKey);
|
||||
/**
|
||||
* Attach directly to the parent model if it exists,
|
||||
* else attach via deferred binding
|
||||
*/
|
||||
if (@$fileRelation->getParent()->exists) {
|
||||
$fileRelation->add($file);
|
||||
} else {
|
||||
$fileRelation->add($file, $this->sessionKey);
|
||||
}
|
||||
|
||||
$file = $this->decorateFileAttributes($file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user