Merge pull request #8793 from wilr/pulls/orm-exception
Throw error message when searchable_field does not return a object
This commit is contained in:
commit
f8f6983773
|
@ -2260,7 +2260,15 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||
|
||||
// Otherwise, use the database field's scaffolder
|
||||
} elseif ($object = $this->relObject($fieldName)) {
|
||||
$field = $object->scaffoldSearchField();
|
||||
if (is_object($object) && $object->hasMethod('scaffoldSearchField')) {
|
||||
$field = $object->scaffoldSearchField();
|
||||
} else {
|
||||
throw new Exception(sprintf(
|
||||
"SearchField '%s' on '%s' does not return a valid DBField instance.",
|
||||
$fieldName,
|
||||
get_class($this)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Allow fields to opt out of search
|
||||
|
|
Loading…
Reference in New Issue