diff -u b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php --- b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php @@ -114,8 +114,7 @@ $value = $this->values[$property_name]; } // If the property is unknown, this will throw an exception. - $this->properties[$property_name] = $this->getTypedDataManager() - ->getPropertyInstance($this, $property_name, $value); + $this->properties[$property_name] = $this->getTypedDataManager()->getPropertyInstance($this, $property_name, $value); } return $this->properties[$property_name]; } @@ -165,13 +164,16 @@ } } } - //If module creator send an array to map dataType and don't setPropertyDefinition, - //Auto creating the PropertyDefinition so that it can be normalized + // If module creator send an array to map dataType and don't define setPropertyDefinition, + // Auto creating the PropertyDefinition so that it can be normalized elseif (get_class($this->getDataDefinition()) == 'Drupal\Core\TypedData\MapDataDefinition') { $values = $this->values; if (is_array($values)) { foreach ($values as $key => $value) { $properties[$key] = \Drupal::typedDataManager()->create( + // Give array's value a DataType,So that drupal can find which normalizer to be used to normalize it + // Because we don't know the type of the value,so we use 'any', + // If you don't want to use 'any',Please define it by yourself use setPropertyDefinition DataDefinition::create('any'), $value, $key