mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX Normalise casing before casting fields
This commit is contained in:
parent
a7c8ce8d0c
commit
6d885ab894
@ -319,9 +319,12 @@ class ViewableData implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
public function castingHelper($field)
|
public function castingHelper($field)
|
||||||
{
|
{
|
||||||
$specs = static::config()->get('casting');
|
// Get casting if it has been configured.
|
||||||
if (isset($specs[$field])) {
|
// DB fields and PHP methods are all case insensitive so we normalise casing before checking.
|
||||||
return $specs[$field];
|
$specs = array_change_key_case(static::config()->get('casting'), CASE_LOWER);
|
||||||
|
$fieldLower = strtolower($field);
|
||||||
|
if (isset($specs[$fieldLower])) {
|
||||||
|
return $specs[$fieldLower];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no specific cast is declared, fall back to failover.
|
// If no specific cast is declared, fall back to failover.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user