From 5bcfbe6622a4ee7ffa21513d4e20784b9ec40079 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 12 Apr 2010 03:16:54 +0000 Subject: [PATCH] BUGFIX: Allow opening of the detail pop-ups of a record on a ComplexTableField attached to a deleted page. (from r94593) (from r96762) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102393 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ComplexTableField.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index ebccb0f59..9162189fe 100755 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -389,6 +389,21 @@ JS; } } + /** + * Return the record in which the CTF resides + */ + function getParentRecord() { + if($this->form && $record = $this->form->getRecord()) { + return $record; + } else { + if($this->sourceID()) { + $parentClass = DataObject::get_by_id($this->getParentClass(), $this->sourceID()); + } else { + $parentClass = singleton($this->getParentClass()); + } + } + } + /** * (Optional) Setter for a correct parent-relation-class. * Defaults to the record loaded into the surrounding form as a fallback. @@ -472,11 +487,7 @@ JS; function getFieldsFor($childData) { // See if our parent class has any many_many relations by this source class if($this->getParentClass()) { - if($this->sourceID()) { - $parentClass = DataObject::get_by_id($this->getParentClass(), $this->sourceID()); - } else { - $parentClass = singleton($this->getParentClass()); - } + $parentClass = $this->getParentRecord(); $manyManyRelations = $parentClass->many_many(); $manyManyRelationName = null;