Fixes bug introduced by #2507
The many-to-many relationship types choke pretty hard on this enhancement, so only use it for the simple one-to-many/one-to-one style relations instead. Fixes #2524
This commit is contained in:
parent
fad4d52e79
commit
afa2c83c3c
|
|
@ -139,9 +139,15 @@ class Relation extends FormWidgetBase
|
|||
$result = $query->getQuery()->get();
|
||||
}
|
||||
|
||||
// Some simpler relations can specify a custom local or foreign "other" key,
|
||||
// which can be detected and implemented here automagically.
|
||||
$primaryKeyName = in_array($relationType, ['hasMany', 'belongsTo', 'hasOne'])
|
||||
? $relationObject->getOtherKey()
|
||||
: $relationModel->getKeyName();
|
||||
|
||||
$field->options = $usesTree
|
||||
? $result->listsNested($nameFrom, $relationObject->getOtherKey())
|
||||
: $result->lists($nameFrom, $relationObject->getOtherKey());
|
||||
? $result->listsNested($nameFrom, $primaryKeyName)
|
||||
: $result->lists($nameFrom, $primaryKeyName);
|
||||
|
||||
return $field;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue