From f6ce5741abeb15ebaac5d83801a76962ee358e51 Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Mon, 13 May 2024 11:21:18 -0300 Subject: [PATCH] Added error when a many_many relationship could not be found --- src/Forms/GridFieldSortableRows.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Forms/GridFieldSortableRows.php b/src/Forms/GridFieldSortableRows.php index df21d18..78e402a 100644 --- a/src/Forms/GridFieldSortableRows.php +++ b/src/Forms/GridFieldSortableRows.php @@ -253,6 +253,10 @@ class GridFieldSortableRows extends AbstractGridFieldComponent implements GridFi if ($many_many) { $schema = Injector::inst()->get(DataObjectSchema::class); $componentDetails = $schema->manyManyComponent(get_class($owner), (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName())); + if (empty($componentDetails)) { + 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); + } + $parentField = $componentDetails['parentField']; $componentField = $componentDetails['childField']; $table = $componentDetails['join']; @@ -483,6 +487,10 @@ class GridFieldSortableRows extends AbstractGridFieldComponent implements GridFi if ($many_many) { $schema = Injector::inst()->get(DataObjectSchema::class); $componentDetails = $schema->manyManyComponent(get_class($owner), (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName())); + if (empty($componentDetails)) { + 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); + } + $parentField = $componentDetails['parentField']; $componentField = $componentDetails['childField']; $table = $componentDetails['join'];