src/Form/RegistrationFormType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Generic\Customer\Customer;
  4. use App\Entity\Generic\User;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints\IsTrue;
  12. use Symfony\Component\Validator\Constraints\Length;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. class RegistrationFormType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('identifier' TextType::class , [
  20.                 'label' => false,
  21.                 'attr' => [
  22.                     'placeholder' => 'پست الکترونیک یا شماره موبایل',
  23.                     'class' => 'mb-3'
  24.                 ]
  25.             ])
  26. //            ->add('agreeTerms', CheckboxType::class, [
  27. //                'mapped' => false,
  28. //                'constraints' => [
  29. //                    new IsTrue([
  30. //                        'message' => 'You should agree to our terms.',
  31. //                    ]),
  32. //                ],
  33. //            ])
  34.             ->add('plainPassword'PasswordType::class, [
  35.                 'label' =>false,
  36.                 // instead of being set onto the object directly,
  37.                 // this is read and encoded in the controller
  38.                 'mapped' => false,
  39.                 'attr' => ['autocomplete' => 'new-password',
  40.                     'placeholder' => 'کلمه عبور انتخابی',
  41.                     'class' => 'mb-3'
  42.                 ],
  43.                 'constraints' => [
  44.                     new NotBlank([
  45.                         'message' => 'Please enter a password',
  46.                     ]),
  47.                     new Length([
  48.                         'min' => 6,
  49.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  50.                         // max length allowed by Symfony for security reasons
  51.                         'max' => 4096,
  52.                     ]),
  53.                 ],
  54.             ])
  55.         ;
  56.     }
  57.     public function configureOptions(OptionsResolver $resolver): void
  58.     {
  59.         $resolver->setDefaults([
  60.             'data_class' => User::class,
  61.         ]);
  62.     }
  63. }