diff --git a/forms/gridfield/GridFieldAddExistingAutocompleter.php b/forms/gridfield/GridFieldAddExistingAutocompleter.php index d1990ef07..e27af945b 100644 --- a/forms/gridfield/GridFieldAddExistingAutocompleter.php +++ b/forms/gridfield/GridFieldAddExistingAutocompleter.php @@ -231,6 +231,11 @@ class GridFieldAddExistingAutocompleter $json = array(); foreach($results as $result) { + // Prevent a circular reference and associated error in CMS/admin + $hideFromSearch = ($gridField->getForm()->getRecord() && ($result->ID == $gridField->getForm()->getRecord()->ID)); + if($hideFromSearch) { + continue; + } $json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result); } return Convert::array2json($json);