Merge pull request #2390 from phptek/2389

Prevent circular refs in `GridFieldAddExistingAutocompleter` when linking DataObjects whose ID == current object's ID
This commit is contained in:
Sean Harvey 2013-09-10 21:43:31 -07:00
commit 58da57dd1b

View File

@ -231,6 +231,11 @@ class GridFieldAddExistingAutocompleter
$json = array(); $json = array();
foreach($results as $result) { 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); $json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result);
} }
return Convert::array2json($json); return Convert::array2json($json);