src/Form/ForgotPasswordType.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Validator\Constraints\NotBlank;
  8. use Symfony\Component\Validator\Constraints\Email;
  9. class ForgotPasswordType extends AbstractType
  10. {
  11.     public function buildForm(FormBuilderInterface $builder, array $options): void
  12.     {
  13.         $builder->add(
  14.             'email',
  15.             EmailType::class, 
  16.             [
  17.                 'label' => 'Email',
  18.                 'required' => true,
  19.                 'attr' => [
  20.                     'placeholder' => 'Email',
  21.                     'class' => 'form-control',
  22.                 ],
  23.                 // Server-side validation constraints
  24.                 'constraints' => [
  25.                     // Ensure the field is not empty
  26.                     new NotBlank([
  27.                         'message' => 'Veuillez entrer votre adresse e-mail.',
  28.                     ]),
  29.                     // Ensure the field contains a valid email address format
  30.                     new Email([
  31.                         'message' => 'Veuillez entrer une adresse e-mail valide.',
  32.                     ]),
  33.                 ],
  34.             ]);
  35.     }
  36. }