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');