mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed resolution of amibiguous has_many foreign keys in ComplexTableField to use the same logic as DataObject (from r88945)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89203 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9809c0164f
commit
5ec83b9bd0
@ -427,16 +427,17 @@ JS;
|
||||
|
||||
/**
|
||||
* Returns the db-fieldname of the currently used relationship.
|
||||
* Note: constructed resolve ambiguous cases in the same manner as
|
||||
* DataObject::getComponentJoinField()
|
||||
*/
|
||||
function getParentIdNameRelation($parentClass, $childClass, $relation) {
|
||||
if($this->parentIdName) return $this->parentIdName;
|
||||
|
||||
$relations = singleton($parentClass)->$relation();
|
||||
$classes = ClassInfo::ancestry($childClass);
|
||||
if($relations) {
|
||||
foreach($relations as $k => $v) {
|
||||
if(array_key_exists($v, $classes)) return $k . 'ID';
|
||||
}
|
||||
$relations = array_flip(singleton($parentClass)->$relation());
|
||||
|
||||
$classes = array_reverse(ClassInfo::ancestry($childClass));
|
||||
foreach($classes as $class) {
|
||||
if(isset($relations[$class])) return $relations[$class] . 'ID';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user