mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Improve support for BackedEnums
This commit is contained in:
parent
ca85e3c491
commit
32f25ef755
@ -700,18 +700,15 @@ class FormField
|
||||
if ($result instanceof Model && $result->hasRelation($key)) {
|
||||
if ($key == $lastField) {
|
||||
$result = $result->getRelationValue($key) ?: $default;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result = $result->{$key};
|
||||
}
|
||||
}
|
||||
elseif (is_array($result)) {
|
||||
} elseif (is_array($result)) {
|
||||
if (!array_key_exists($key, $result)) {
|
||||
return $default;
|
||||
}
|
||||
$result = $result[$key];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!isset($result->{$key})) {
|
||||
return $default;
|
||||
}
|
||||
@ -719,6 +716,10 @@ class FormField
|
||||
}
|
||||
}
|
||||
|
||||
if ($result instanceof BackedEnum) {
|
||||
$result = $result->value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user