From 41fedb9e276ec72f2c7432414711a4a2fa3316ea Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Thu, 22 Aug 2019 15:30:16 -0300 Subject: [PATCH] BUGFIX: Fixed crash when the value of the FileAttachmentField is set from a DataObject --- src/FileAttachmentField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FileAttachmentField.php b/src/FileAttachmentField.php index 3120b23..be368f7 100644 --- a/src/FileAttachmentField.php +++ b/src/FileAttachmentField.php @@ -549,12 +549,12 @@ public function setValue($val, $data = array()) // an already saved DataObject. $fieldName = $this->getName(); $ids = array(); - if ($data->hasOneComponent($fieldName)) { + if ($data->getSchema()->hasOneComponent(get_class($data), $fieldName)) { $id = $data->{$fieldName.'ID'}; if ($id) { $ids[] = $id; } - } else if ($data->hasManyComponent($fieldName) || $data->manyManyComponent($fieldName)) { + } else if ($data->getSchema()->hasManyComponent(get_class($data), $fieldName) || $data->getSchema()->manyManyComponent(get_class($data), $fieldName)) { $files = $data->{$fieldName}(); if ($files) { foreach ($files as $file) {