Skip to content

Commit

Permalink
BUGFIX: Fixed crash when the value of the FileAttachmentField is set …
Browse files Browse the repository at this point in the history
…from a DataObject
  • Loading branch information
UndefinedOffset committed Aug 22, 2019
1 parent 578ff19 commit 41fedb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/FileAttachmentField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 41fedb9

Please sign in to comment.