Added error when a many_many relationship could not be found

This commit is contained in:
UndefinedOffset 2024-05-13 11:21:18 -03:00
parent b1febae3d8
commit f6ce5741ab
No known key found for this signature in database
GPG Key ID: 59C4EE2B6468B796
1 changed files with 8 additions and 0 deletions

View File

@ -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'];