8000 bug #10077 Fix select attributes according to recent Symfony form cha… · Sylius/SyliusAttributeBundle@03759fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 03759fa

Browse files
authored
bug #10077 Fix select attributes according to recent Symfony form changes (Zales0123)
This PR was merged into the 1.2 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | related to symfony/symfony#29307 | License | MIT Due to the latest Symfony 4.1.10/3.4.21 release and changes introduced in linked PR, a bug in select attribute type araised 🌤 Apparently, possible to select values in attribute configuration was saved with `TextType` form type, even though `SelectAttributeValueTranslationsType` should be used. It was somehow parsed before, but know it's not possible and this PR fixes this absurdity 🖖 Commits ------- 51f7ec2481d67270ed66b9879fc57702e4fafb76 Fix select attributes according to recent Symfony form changes b80fa003a4a279c9204465b6189027db50c2285e Fix test in ResourceBundle (taken from #10062)
2 parents 7d357e7 + e670107 commit 03759fa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Form/Type/AttributeType/Configuration/SelectAttributeChoicesCollectionType.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(TranslationLocaleProviderInterface $localeProvider)
3636
*/
3737
public function buildForm(FormBuilderInterface $builder, array $options): void
3838
{
39-
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
39+
$builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
4040
$data = $event->getData();
4141
$form = $event->getForm();
4242

@@ -57,8 +57,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5757
$fixedData[$newKey] = $this->resolveValues($values);
5858

5959
if ($form->offsetExists($key)) {
60-
$form->offsetUnset($key);
61-
$form->offsetSet(null, $newKey);
60+
$type = get_class($form->get($key)->getConfig()->getType()->getInnerType());
61+
$options = $form->get($key)->getConfig()->getOptions();
62+
63+
$form->remove($key);
64+
$form->add($newKey, $type, $options);
6265
}
6366
}
6467

0 commit comments

Comments
 (0)
0