diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 327e7abb05..cd3534d512 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Doctrine\Form\Type; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader; @@ -107,7 +108,7 @@ abstract class DoctrineType extends AbstractType implements ResetInterface public function buildForm(FormBuilderInterface $builder, array $options) { - if ($options['multiple']) { + if ($options['multiple'] && interface_exists(Collection::class)) { $builder ->addEventSubscriber(new MergeDoctrineCollectionListener()) ->addViewTransformer(new CollectionToArrayTransformer(), true) diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 849d2069ad..819af85220 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -17,7 +17,6 @@ ], "require": { "php": "^7.1.3", - "doctrine/collections": "~1.0", "doctrine/event-manager": "~1.0", "doctrine/persistence": "~1.0", "symfony/contracts": "^1.0", @@ -39,6 +38,7 @@ "symfony/translation": "~3.4|~4.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.6", + "doctrine/collections": "~1.0", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.4", "doctrine/orm": "^2.4.5",