diff --git a/src/ORM/UnsavedRelationList.php b/src/ORM/UnsavedRelationList.php index 4a6a702f296..9e078c63e47 100644 --- a/src/ORM/UnsavedRelationList.php +++ b/src/ORM/UnsavedRelationList.php @@ -257,6 +257,9 @@ public function first() public function last() { $item = end($this->items) ?: null; + if (is_numeric($item)) { + $item = DataObject::get_by_id($this->dataClass, $item); + } if ($item && !empty($this->extraFields[key($this->items)])) { $item->update($this->extraFields[key($this->items)]); }