From 884ad43916957993d0def9e29e5a78b255484499 Mon Sep 17 00:00:00 2001 From: Hayden Smith Date: Sun, 7 Dec 2008 21:29:54 +0000 Subject: [PATCH] BUGFIX: Fixed an aliasing problem when saving popup items, and a bug with when associating a new record with the parent ID associated with the field. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@67580 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ComplexTableField.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index e01131841..041f34704 100755 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -460,7 +460,7 @@ JS; if(!$childData->ID && $this->getParentClass()) { // make sure the relation-link is existing, even if we just add the sourceClass and didn't save it $parentIDName = $this->getParentIdName( $this->getParentClass(), $this->sourceClass() ); - $childData->$parentIDName = $childData->ID; + $childData->$parentIDName = $this->sourceID(); } $detailFields = $this->getCustomFieldsFor($childData); @@ -713,8 +713,10 @@ class ComplexTableField_ItemRequest extends RequestHandler { * @see Form::ReferencedField */ function saveComplexTableField($data, $form, $request) { - $form->saveInto($this->dataObj()); - $this->dataObj()->write(); + $dataObject = $this->dataObj(); + + $form->saveInto($dataObject); + $dataObject->write(); $closeLink = sprintf( '(%s)', @@ -722,8 +724,8 @@ class ComplexTableField_ItemRequest extends RequestHandler { ); $message = sprintf( _t('ComplexTableField.SUCCESSEDIT', 'Saved %s %s %s'), - $this->dataObj()->singular_name(), - '"' . $this->dataObj()->Title . '"', + $dataObject->singular_name(), + '"' . $dataObject->Title . '"', $closeLink ); $form->sessionMessage($message, 'good');