Skip to content

Commit

Permalink
Fix select attributes according to recent Symfony form changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jan 8, 2019
1 parent 3ee025b commit e670107
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -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();

Expand All @@ -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);
}
}

Expand Down

0 comments on commit e670107

Please sign in to comment.