Skip to content

Commit

Permalink
Merge pull request #100 from webbuilders-group/hasonecomponent_fix
Browse files Browse the repository at this point in the history
BUGFIX: Fixed crash when the value of the FileAttachmentField is set from a DataObject
  • Loading branch information
Aaron Carlino authored Aug 22, 2019
2 parents 578ff19 + 41fedb9 commit 5cec6fb
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 5cec6fb

Please sign in to comment.