mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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
This commit is contained in:
parent
5a313be83e
commit
f55ba36a65
@ -124,6 +124,7 @@ class ComponentSet extends DataObjectSet {
|
|||||||
protected function loadChildIntoDatabase($item, $extraFields = null) {
|
protected function loadChildIntoDatabase($item, $extraFields = null) {
|
||||||
if($this->type == '1-to-many') {
|
if($this->type == '1-to-many') {
|
||||||
$child = DataObject::get_by_id($this->childClass,$item->ID);
|
$child = DataObject::get_by_id($this->childClass,$item->ID);
|
||||||
|
if (!$child) $child = $item;
|
||||||
$joinField = $this->joinField;
|
$joinField = $this->joinField;
|
||||||
$child->$joinField = $this->ownerObj->ID;
|
$child->$joinField = $this->ownerObj->ID;
|
||||||
$child->write();
|
$child->write();
|
||||||
|
Loading…
Reference in New Issue
Block a user