@@ -439,7 +439,7 @@ private function hydrateValue(mixed $value, LivePropMetadata $propMetadata, obje
439439 if ($ propMetadata ->collectionValueType () && Type::BUILTIN_TYPE_OBJECT === $ propMetadata ->collectionValueType ()->getBuiltinType ()) {
440440 $ collectionClass = $ propMetadata ->collectionValueType ()->getClassName ();
441441 foreach ($ value as $ key => $ objectItem ) {
442- $ value [$ key ] = $ this ->hydrateObjectValue ($ objectItem , $ collectionClass , true , $ parentObject ::class, sprintf ('%s.%s ' , $ propMetadata ->getName (), $ key ), $ parentObject );
442+ $ value [$ key ] = $ this ->hydrateObjectValue ($ objectItem , $ collectionClass , true , $ propMetadata -> getFormat (), $ parentObject ::class, sprintf ('%s.%s ' , $ propMetadata ->getName (), $ key ), $ parentObject );
443443 }
444444 }
445445
@@ -461,10 +461,10 @@ private function hydrateValue(mixed $value, LivePropMetadata $propMetadata, obje
461461 return $ value ;
462462 }
463463
464- return $ this ->hydrateObjectValue ($ value , $ propMetadata ->getType (), $ propMetadata ->allowsNull (), $ parentObject ::class, $ propMetadata ->getName (), $ parentObject );
464+ return $ this ->hydrateObjectValue ($ value , $ propMetadata ->getType (), $ propMetadata ->allowsNull (), $ propMetadata -> getFormat (), $ parentObject ::class, $ propMetadata ->getName (), $ parentObject );
465465 }
466466
467- private function hydrateObjectValue (mixed $ value , string $ className , bool $ allowsNull , string $ componentClassForError , string $ propertyPathForError , object $ component ): ?object
467+ private function hydrateObjectValue (mixed $ value , string $ className , bool $ allowsNull , ? string $ dateFormat , string $ componentClassForError , string $ propertyPathForError , object $ component ): ?object
468468 {
469469 // enum
470470 if (is_a ($ className , \BackedEnum::class, true )) {
@@ -485,6 +485,10 @@ private function hydrateObjectValue(mixed $value, string $className, bool $allow
485485 throw new BadRequestHttpException (sprintf ('The model path "%s" was sent an invalid data type "%s" for a date. ' , $ propertyPathForError , get_debug_type ($ value )));
486486 }
487487
488+ if (null !== $ dateFormat ) {
489+ return $ className ::createFromFormat ($ dateFormat , $ value );
490+ }
491+
488492 return new $ className ($ value );
489493 }
490494
0 commit comments