diff --git a/application/src/Api/Adapter/ValueHydrator.php b/application/src/Api/Adapter/ValueHydrator.php index c6431fd37b..f77c33ea48 100644 --- a/application/src/Api/Adapter/ValueHydrator.php +++ b/application/src/Api/Adapter/ValueHydrator.php @@ -73,7 +73,7 @@ public function hydrate(Request $request, Resource $entity, $entityManager = $adapter->getEntityManager(); $dataTypes = $adapter->getServiceLocator()->get('Omeka\DataTypeManager'); - // Iterate the representation data. Note that we ignore terms. + // Iterate the representation data. $valuePassed = false; foreach ($representation as $term => $valuesData) { if (!is_array($valuesData)) { @@ -113,10 +113,12 @@ public function hydrate(Request $request, Resource $entity, // Hydrate a single value. $value->setResource($entity); $value->setType($dataType->getName()); - $value->setProperty($entityManager->getReference( - 'Omeka\Entity\Property', - $valueData['property_id'] - )); + // If the property_id is "auto", look out to the value's key for + // a property term. + $property = 'auto' === $valueData['property_id'] + ? $adapter->getPropertyByTerm($term) + : $entityManager->getReference('Omeka\Entity\Property', $valueData['property_id']); + $value->setProperty($property); if (isset($valueData['is_public'])) { $value->setIsPublic($valueData['is_public']); }