src/Form/RegistrationFormType.php line 16

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\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints\IsTrue;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. class RegistrationFormType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $builder
  18.             ->add('email',EmailType::class, ['label' =>'','attr' => ['class' => 'form-style','Placeholder' => 'Email']])
  19.             ->add('plainPassword'PasswordType::class, [
  20.                 // instead of being set onto the object directly,
  21.                 // this is read and encoded in the controller
  22.                 'mapped' => false,
  23.                 'attr' => ['autocomplete' => 'new-password''class' => 'form-style','Placeholder' => 'Mot de passe'],
  24.                 'constraints' => [
  25.                     new NotBlank([
  26.                         'message' => 'Please enter a password',
  27.                     ]),
  28.                     new Length([
  29.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  30.                         // max length allowed by Symfony for security reasons
  31.                         'max' => 4096,
  32.                     ]),
  33.                 ],
  34.             ])
  35.             ->add('confirmpassword'PasswordType::class, [
  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''class' => 'form-style' ,'Placeholder' => 'Retaper votre mot de passe'],
  40.                 'constraints' => [
  41.                     new Length([
  42.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  43.                         // max length allowed by Symfony for security reasons
  44.                         'max' => 4096,
  45.                     ]),
  46.                 ],
  47.             ])
  48.         ;
  49.     }
  50.     public function configureOptions(OptionsResolver $resolver): void
  51.     {
  52.         $resolver->setDefaults([
  53.             'data_class' => User::class,
  54.         ]);
  55.     }
  56. }