Update src/Sylius/Bundle/CoreBundle/Form/Type/Checkout/AddressType.php

Co-authored-by: Victor Vasiloi <victor.vasiloi@gmail.com>
This commit is contained in:
Jibé Barth 2023-12-09 10:06:15 +01:00 committed by GitHub
parent 66231b4ac2
commit 282d035167
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -144,16 +144,15 @@ final class AddressType extends AbstractResourceType
$event->setData($orderData);
})
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options): void {
->addEventListener(FormEvents::PRE_SUBMIT, static function (FormEvent $event): void {
$orderData = $event->getData();
$form = $event->getForm();
if ($options['customer'] instanceof CustomerInterface && array_key_exists('customer', $orderData)) {
if (array_key_exists('customer', $orderData) && !$form->has('customer')) {
// Logged-in user try to submit customer while reloading page after login
unset($orderData['customer']);
$event->getForm()->remove('customer');
$event->setData($orderData);
}
$event->setData($orderData);
})
;
}