src/Form/RegistrationFormType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\User;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  8. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Validator\Constraints\IsTrue;
  13. use Symfony\Component\Validator\Constraints\Length;
  14. use Symfony\Component\Validator\Constraints\NotBlank;
  15. class RegistrationFormType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options): void
  18.     {
  19.         $builder
  20.             ->add('email'EmailType::class, [
  21.                 'required' => true,
  22.                 'label' => false,
  23.             ])
  24.             ->add('name'TextType::class, [
  25.                 'required' => true,
  26.                 'label' => false,
  27.             ])
  28.             ->add('surname'TextType::class, [
  29.                 'required' => true,
  30.                 'label' => false,
  31.             ])
  32.             ->add('phone'TextType::class, [
  33.                 'label' => false,
  34.             ])
  35.             ->add('code'TextType::class, [
  36.                 'label' => false,
  37.                 'required' => false,
  38.             ])
  39.             ->add('agreeTerms'CheckboxType::class, [
  40.                 'label' => '<a href="https://www.efsgroup.cz/download/podminky-uzivani.pdf" target="_blank" class="fw-bold">Souhlasím s podmínkami užívání webu</a>',
  41.                 'label_html' => true,
  42.                 'constraints' => [
  43.                     new IsTrue([
  44.                         'message' => 'Musíte souhlasit s podmínkami užívání webu.',
  45.                     ]),
  46.                 ],
  47.             ])
  48.             ->add('agreeTerms1'CheckboxType::class, [
  49.                 'label' => '<a href="https://www.efsgroup.cz/download/informacni-povinost.pdf" target="_blank" class="fw-bold">Souhlasím s podmínkami zpracování osobních údajů</a>',
  50.                 'label_html' => true,
  51.                 'constraints' => [
  52.                     new IsTrue([
  53.                         'message' => 'Musíte souhlasit s podmínkami zpracování osobních údajů.',
  54.                     ]),
  55.                 ],
  56.             ])
  57.             ->add('agreeTerms2'CheckboxType::class, [
  58.                 'label' => '<a href="https://www.efsgroup.cz/download/souhlas.pdf" target="_blank" class="fw-bold">Souhlasím se zasíláním obchodních sdělení</a>',
  59.                 'label_html' => true
  60.             ])
  61.             ->add('plainPassword'RepeatedType::class, [
  62.                 // instead of being set onto the object directly,
  63.                 // this is read and encoded in the controller
  64.                 'mapped' => false,
  65.                 'type' => PasswordType::class,
  66.                 'attr' => ['autocomplete' => 'new-password'],
  67.                 'constraints' => [
  68.                     new NotBlank([
  69.                         'message' => 'Please enter a password',
  70.                     ]),
  71.                     new Length([
  72.                         'min' => 6,
  73.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  74.                         // max length allowed by Symfony for security reasons
  75.                         'max' => 4096,
  76.                     ]),
  77.                 ],
  78.             ])
  79.         ;
  80.     }
  81.     public function configureOptions(OptionsResolver $resolver): void
  82.     {
  83.         $resolver->setDefaults([
  84.             'data_class' => User::class,
  85.             'attr' => [
  86.                 'data-controller' => 'register-form',
  87.                 'data-action' => 'submit->register-form#submitForm'
  88.             ]
  89.         ]);
  90.     }
  91. }