src/Form/GetResetPasswordEmailForm.php line 18

  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\Extension\Core\Type\TextType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use  Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  8. use Symfony\Component\Validator\Constraints\Email;
  9. use Symfony\Component\Validator\Constraints\NotBlank;
  10. /**
  11.  * Reset password email form
  12.  *
  13.  * @package App\Form\
  14.  */
  15. class GetResetPasswordEmailForm extends AbstractType
  16. {
  17.     private UrlGeneratorInterface $urlGenerator;
  18.     public function __construct(UrlGeneratorInterface $urlGenerator)
  19.     {
  20.         $this->urlGenerator $urlGenerator;
  21.     }
  22.     /**
  23.      * @inheritDoc
  24.      *
  25.      * @param FormBuilderInterface $builder
  26.      * @param array $options
  27.      *
  28.      * @throws \Symfony\Component\Routing\Exception\InvalidParameterException
  29.      * @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
  30.      * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
  31.      */
  32.     public function buildForm(FormBuilderInterface $builder, array $options)
  33.     {
  34.         $builder->setAction($this->urlGenerator->generate('motDePasseRecuperation'))
  35.             ->add('email',EmailType::class, [
  36.                 'label' => 'Email',
  37.                 'required' => true,
  38.                 'constraints' => [
  39.                     new NotBlank([
  40.                         'message' => 'Veuillez saisir votre email',
  41.                     ]),
  42.                     new Email([
  43.                         'message' => 'Veuillez saisir un email valide',
  44.                     ]),
  45.                 ],
  46.                 'attr' => ['class' => 'form-control mt-2 mb-2'],
  47.             ]);
  48.     }
  49. }