From f55ba36a6528053e31d4fda66ce1fb9c9e4f9740 Mon Sep 17 00:00:00 2001 From: Mark Rickerby Date: Mon, 10 Mar 2008 21:48:13 +0000 Subject: [PATCH] fixing bug with in-memory child objects not having their parent ID field updated via the ->add() method git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@50808 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/ComponentSet.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/model/ComponentSet.php b/core/model/ComponentSet.php index 412667880..a6bdb1bf2 100755 --- a/core/model/ComponentSet.php +++ b/core/model/ComponentSet.php @@ -124,6 +124,7 @@ class ComponentSet extends DataObjectSet { protected function loadChildIntoDatabase($item, $extraFields = null) { if($this->type == '1-to-many') { $child = DataObject::get_by_id($this->childClass,$item->ID); + if (!$child) $child = $item; $joinField = $this->joinField; $child->$joinField = $this->ownerObj->ID; $child->write();