From 53346af02664a1dd38fcb3a4b123999056cf8c83 Mon Sep 17 00:00:00 2001 From: "Javi H. Gil" Date: Wed, 28 May 2025 10:41:01 +0200 Subject: [PATCH] Prevent collection type errors --- src/Form/Type/PolymorphicCollectionType.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Form/Type/PolymorphicCollectionType.php b/src/Form/Type/PolymorphicCollectionType.php index 9ad3ede..3c96f5e 100644 --- a/src/Form/Type/PolymorphicCollectionType.php +++ b/src/Form/Type/PolymorphicCollectionType.php @@ -5,6 +5,7 @@ use Softspring\Component\PolymorphicFormType\Form\DataTransformer\NodeDataTransformer; use Softspring\Component\PolymorphicFormType\Form\Discriminator\NodeDiscriminator; use Softspring\Component\PolymorphicFormType\Form\EventListener\NodesResizeFormListener; +use Softspring\Component\PolymorphicFormType\Form\Type\Node\AbstractNodeType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\Extension\Core\Type\CollectionType; @@ -96,7 +97,7 @@ public function buildView(FormView $view, FormInterface $form, array $options): */ protected function getFormFactory(array $options): FormFactory { - if ($options['form_factory']) { + if ($options['form_factory'] ?? false) { if (!$options['form_factory'] instanceof FormFactory) { throw new RuntimeException('form_factory option must contain an instance of FormFactory'); } @@ -112,7 +113,7 @@ protected function getFormFactory(array $options): FormFactory /** * Configure event subscriber for resizing with data transformer. */ - protected function configureResizeEventSubscriber(FormBuilderInterface $builder, array $options) + protected function configureResizeEventSubscriber(FormBuilderInterface $builder, array $options): void { if (empty($options['discriminator_map'])) { throw new RuntimeException('discriminator_map must be set');