mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Fixes an issue where unfilled relations are not populated in forms
This commit is contained in:
parent
d8ca802401
commit
4fa00f1c7b
@ -600,14 +600,16 @@ class Form extends WidgetBase
|
||||
|
||||
/*
|
||||
* Loop the field key parts and build a value.
|
||||
* To support relations only the last ield should return the
|
||||
* To support relations only the last field should return the
|
||||
* relation value, all others will look up the relation object as normal.
|
||||
*/
|
||||
foreach ($keyParts as $key) {
|
||||
|
||||
if ($key == $lastField && $result instanceof Model && $result->hasRelation($key)) {
|
||||
if (!$result = $result->getRelationValue($key))
|
||||
return $defaultValue;
|
||||
if ($result instanceof Model && $result->hasRelation($key)) {
|
||||
if ($key == $lastField)
|
||||
$result = $result->getRelationValue($key) ?: $defaultValue;
|
||||
else
|
||||
$result = $result->{$key};
|
||||
}
|
||||
elseif (is_array($result)) {
|
||||
if (!array_key_exists($key, $result)) return $defaultValue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user