src/Form/DeliveryAddressFormType.php line 28

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. namespace App\Form;
  15. use Pimcore\Localization\LocaleService;
  16. use Symfony\Component\Form\AbstractType;
  17. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  18. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  19. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  20. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  21. use Symfony\Component\Form\Extension\Core\Type\TextType;
  22. use Symfony\Component\Form\FormBuilderInterface;
  23. use Symfony\Component\OptionsResolver\OptionsResolver;
  24. class DeliveryAddressFormType extends AbstractType
  25. {
  26.     /**
  27.      * @var LocaleService
  28.      */
  29.     protected $locale;
  30.     public function __construct(LocaleService $locale)
  31.     {
  32.         $this->locale $locale;
  33.     }
  34.     /**
  35.      * @inheritDoc
  36.      */
  37.     public function buildForm(FormBuilderInterface $builder, array $options)
  38.     {
  39.         $regionArray $this->locale->getDisplayRegions();
  40.         $builder
  41.             ->add('email'EmailType::class, [
  42.                 'label' => 'general.email'
  43.             ])
  44.             ->add('firstname'TextType::class, [
  45.                 'label' => 'general.firstname'
  46.             ])
  47.             ->add('lastname'TextType::class, [
  48.                 'label' => 'general.lastname'
  49.             ])
  50.             ->add('company'TextType::class, [
  51.                 'label' => 'general.company',
  52.                 'required' => false
  53.             ])
  54.             ->add('street'TextType::class, [
  55.                 'label' => 'general.street'
  56.             ])
  57.             ->add('zip'TextType::class, [
  58.                 'label' => 'general.zip'
  59.             ])
  60.             ->add('city'TextType::class, [
  61.                 'label' => 'general.city'
  62.             ])
  63.             ->add('countryCode'ChoiceType::class, [
  64.                 'label' => 'general.country',
  65.                 'choices' => [
  66.                     strtoupper($regionArray['AT']) => 'AT',
  67.                     strtoupper($regionArray['DE']) => 'DE'
  68.                 ],
  69.                 'choice_translation_domain' => false
  70.             ])
  71.             ->add('terms'CheckboxType::class, [
  72.                 'label' => 'checkout.terms'
  73.             ])
  74.             ->add('_submit'SubmitType::class, [
  75.                 'label' => 'checkout.submit-address'
  76.             ]);
  77.     }
  78.     /**
  79.      * @inheritDoc
  80.      */
  81.     public function getBlockPrefix()
  82.     {
  83.         // we need to set this to an empty string as we want _username as input name
  84.         // instead of login_form[_username] to work with the form authenticator out
  85.         // of the box
  86.         return '';
  87.     }
  88.     /**
  89.      * @inheritDoc
  90.      */
  91.     public function configureOptions(OptionsResolver $resolver)
  92.     {
  93.     }
  94. }