src/Form/Extension/CheckoutShipmentTypeExtension.php
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
                $form = $event->getForm();

                $form->add('pickup_id', TextType::class, [
                    'required' => false,
                    'label' => 'sylius.form.checkout.shipping_method.pickup_id',
                ]);
            })
            ->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
                $data = $event->getData();

                $method = $this->shippingMethodRepository->findOneBy(['code' => $data['method']]);
                if ($method) {
                    $calculator = $this->calculatorRegistry->get($method->getCalculator());

                    if ($calculator instanceof PickupCalculatorInterface) {
                        if (!isset($data['pickup_id'])) {
                            $event->getForm()->addError(
                                new FormError($this->translator->trans('pickup.form.shipment.error.pickup_id'))
                            );
                        }
                    }
                }
            });
    }
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
                $form = $event->getForm();

                $form->add('pickup_id', TextType::class, [
                    'required' => false,
                    'label' => 'sylius.form.checkout.shipping_method.pickup_id',
                ]);
            })
            ->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
                $data = $event->getData();

                $method = $this->shippingMethodRepository->findOneBy(['code' => $data['method']]);
                if ($method) {
                    $calculator = $this->calculatorRegistry->get($method->getCalculator());

                    if ($calculator instanceof PickupCalculatorInterface) {
                        if (!isset($data['pickup_id'])) {
                            $event->getForm()->addError(
                                new FormError($this->translator->trans('pickup.form.shipment.error.pickup_id'))
                            );
                        }
                    }
                }
            });
    }
{@inheritdoc}