From 46d28cd55da24a69ec111c3ea749af3e18f177ec Mon Sep 17 00:00:00 2001 From: William DURAND Date: Sat, 11 Feb 2012 18:52:37 +0100 Subject: [PATCH] [Propel] Fixed the CollectionToArray transformer --- .../Form/DataTransformer/CollectionToArrayTransformer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php b/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php index ff1399b987..210d2c256f 100644 --- a/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php @@ -35,7 +35,11 @@ class CollectionToArrayTransformer implements DataTransformerInterface throw new UnexpectedTypeException($collection, '\PropelCollection'); } - return $collection->toArray(); + // A PropelCollection is ArrayAccess, to cast the collection + // into array is enough to transform the collection in an array. + // Never use toArray() on a PropelCollection as it puts all data + // in array, not just the collection. + return (array) $collection; } public function reverseTransform($array)