- Prevent circular references in `GridFieldAddExistingAutocompleter` when linking DataObjects whose ID matches the current object to which the gridfield is attached.
This commit is contained in:
Russell Michell 2013-09-05 13:40:26 +12:00
parent daa0b3cb79
commit 128c33b82c

View File

@ -231,7 +231,11 @@ class GridFieldAddExistingAutocompleter
$json = array();
foreach($results as $result) {
$json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result);
// Prevent a circular reference and associated error in CMS/admin
$showInSearch = ($result->ID != $gridField->getForm()->getRecord()->ID);
if($showInSearch) {
$json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result);
}
}
return Convert::array2json($json);
}