Adds support for objects (relations) when reading form data

This commit is contained in:
Sam Georges 2014-05-18 16:09:54 +10:00
parent f7373da55e
commit 5091fd08c6

View File

@ -509,10 +509,16 @@ class Form extends WidgetBase
* This won't execute for standard field names.
*/
foreach ($keyParts as $key) {
if (!is_array($result) || !array_key_exists($key, $result))
return $defaultValue;
$result = $result[$key];
if (is_array($result)) {
if (!array_key_exists($key, $result)) return $defaultValue;
$result = $result[$key];
}
else {
if (!isset($result->{$key})) return $defaultValue;
$result = $result->{$key};
}
}
return $result;