Skip to content

Commit f6ce574

Browse files
Added error when a many_many relationship could not be found
1 parent b1febae commit f6ce574

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/Forms/GridFieldSortableRows.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ protected function fixSortColumn($gridField, SS_List $dataList)
253253
if ($many_many) {
254254
$schema = Injector::inst()->get(DataObjectSchema::class);
255255
$componentDetails = $schema->manyManyComponent(get_class($owner), (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName()));
256+
if (empty($componentDetails)) {
257+
user_error('Could not find the relationship "' . (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName()) . '" on "' . get_class($owner) . '"', E_USER_ERROR);
258+
}
259+
256260
$parentField = $componentDetails['parentField'];
257261
$componentField = $componentDetails['childField'];
258262
$table = $componentDetails['join'];
@@ -483,6 +487,10 @@ protected function saveGridRowSort(GridField $gridField, $data)
483487
if ($many_many) {
484488
$schema = Injector::inst()->get(DataObjectSchema::class);
485489
$componentDetails = $schema->manyManyComponent(get_class($owner), (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName()));
490+
if (empty($componentDetails)) {
491+
user_error('Could not find the relationship "' . (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName()) . '" on "' . get_class($owner) . '"', E_USER_ERROR);
492+
}
493+
486494
$parentField = $componentDetails['parentField'];
487495
$componentField = $componentDetails['childField'];
488496
$table = $componentDetails['join'];

0 commit comments

Comments
 (0)