diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php index 91ff7c755..85504b1a6 100644 --- a/system/src/Grav/Framework/Flex/FlexForm.php +++ b/system/src/Grav/Framework/Flex/FlexForm.php @@ -496,12 +496,7 @@ class FlexForm implements FlexFormInterface { /** @var FlexObject $object */ $object = clone $this->getObject(); - $object->update($data); - - if ($files && method_exists($object, 'upload')) { - $object->upload($files); - } - + $object->update($data, $files); $object->save(); $this->setObject($object); diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 1194248c2..57f6f57aa 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -118,10 +118,6 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface // Validate and filter the incoming data. $blueprint = $this->getFlexDirectory()->getBlueprint(); - if ($files && method_exists($this, 'updateMediaFiles')) { - $this->updateMediaFiles($files); - } - if ($data) { // Filter updated data. $this->filterElements($data); @@ -138,6 +134,10 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface $this->setElements($data); } + if ($files && method_exists($this, 'updateMediaFiles')) { + $this->updateMediaFiles($files); + } + return $this; }