From bde465d77ccbec7396a7d747b19ba9d255c0b127 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Sun, 2 Dec 2007 21:24:01 +0000 Subject: [PATCH] ManyMany Self Relation Problem Fixing (merged from branches/2.2.0@45907, r45025) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@46091 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ManyManyComplexTableField.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forms/ManyManyComplexTableField.php b/forms/ManyManyComplexTableField.php index d4da9b239..ba5e0fd81 100644 --- a/forms/ManyManyComplexTableField.php +++ b/forms/ManyManyComplexTableField.php @@ -21,9 +21,12 @@ class ManyManyComplexTableField extends HasManyComplexTableField { } } $source = $this->sourceClass; + $sourceField = $this->sourceClass; + if( $this->manyManyParentClass == $source ) + $sourceField = 'Child'; $parentID = $this->controller->ID; - $this->sourceJoin .= " LEFT JOIN `$manyManyTable` ON ( `$source`.`ID` = `{$source}ID` AND `{$this->manyManyParentClass}ID` = '$parentID' )"; + $this->sourceJoin .= " LEFT JOIN `$manyManyTable` ON ( `$source`.`ID` = `{$sourceField}ID` AND `{$this->manyManyParentClass}ID` = '$parentID' )"; $this->joinField = 'Checked'; }