mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
commit
58da57dd1b
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user