src/Form/JoinFormType.php line 33

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\NumberType;
  21. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  22. use Symfony\Component\Form\Extension\Core\Type\TextType;
  23. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  24. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  25. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  26. use Symfony\Component\Form\FormBuilderInterface;
  27. use Symfony\Component\OptionsResolver\OptionsResolver;
  28. use Symfony\Component\Validator\Constraints as Assert;
  29. class JoinFormType extends AbstractType
  30. {
  31.     /**
  32.      * @var LocaleService
  33.      */
  34.     /*  protected $locale;
  35.     public function __construct(LocaleService $locale)
  36.     {
  37.         $this->locale = $locale;
  38.     } */
  39.     /**
  40.      * @inheritDoc
  41.      */
  42.     public function buildForm(FormBuilderInterface $builder, array $options)
  43.     {
  44.         /* $regionArray = $this->locale->getDisplayRegions(); */
  45.         $builder
  46.         ->add('email'EmailType::class, [
  47.             'required' => true,
  48.             'constraints' => [
  49.                 new Assert\Email(['message' => 'Email not valid.']),
  50.             ]
  51.         ])
  52.         ->add('firstname'TextType::class, [
  53.             'required' => true,
  54.             'constraints' => [
  55.                 new Assert\NotBlank(['message' => 'Firstname cannot be blank.']),
  56.             ]
  57.         ])
  58.         ->add('lastname'TextType::class, [
  59.             'required' => true,
  60.             'constraints' => [
  61.                 new Assert\NotBlank(['message' => 'Surname cannot be blank.']),
  62.             ]
  63.         ])
  64.         ->add('password'RepeatedType::class, [
  65.             'type' => PasswordType::class,
  66.             'invalid_message' => 'The password fields must match.',
  67.             'required' => true,
  68.             'constraints' => [
  69.                 new Assert\Length([
  70.                 'min' => 8,
  71.                 'max' => 200,
  72.                 'minMessage' => 'Your password must be at least 8 characters long',
  73.                 'maxMessage' => 'Your password cannot be longer than 200 characters',
  74.             ])],
  75.             'first_options'  => ['label' => 'Password''error_bubbling' => true],
  76.             'second_options' => ['label' => 'Repeat Password'],
  77.         ])->add('submit'SubmitType::class, [
  78.             'label' => 'Proceed to payment',
  79.             'attr' => [
  80.                 'class' => 'oscare-primary-btn'
  81.             ]
  82.         ])->add('termsAndPrivacy'CheckboxType::class, [
  83.             'required' => true
  84.         ])->add('consent'CheckboxType::class, [
  85.             'required' => false
  86.         ]);
  87.     }
  88.     /**
  89.      * @inheritDoc
  90.      */
  91.     public function getBlockPrefix()
  92.     {
  93.         // we need to set this to an empty string as we want _username as input name
  94.         // instead of login_form[_username] to work with the form authenticator out
  95.         // of the box
  96.         return '';
  97.     }
  98.     /**
  99.      * @inheritDoc
  100.      */
  101.     public function configureOptions(OptionsResolver $resolver)
  102.     {
  103.     }
  104. }