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) {