diff --git a/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php b/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php index 8e0ac35..89141d1 100644 --- a/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php +++ b/Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php @@ -36,7 +36,7 @@ public function __construct(TranslationLocaleProviderInterface $localeProvider) */ public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { + $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { $data = $event->getData(); $form = $event->getForm(); @@ -57,8 +57,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $fixedData[$newKey] = $this->resolveValues($values); if ($form->offsetExists($key)) { - $form->offsetUnset($key); - $form->offsetSet(null, $newKey); + $type = get_class($form->get($key)->getConfig()->getType()->getInnerType()); + $options = $form->get($key)->getConfig()->getOptions(); + + $form->remove($key); + $form->add($newKey, $type, $options); } }