src/Form/EmailFormType.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Validator\Constraints\Email;
  9. use Symfony\Component\Validator\Constraints\NotBlank;
  10. class EmailFormType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('email'EmailType::class, [
  16.                 'attr' => [
  17.                     'placeholder' => 'form.email',
  18.                 ],
  19.                 'constraints' => [
  20.                     new NotBlank(['message' => 'form.password.not_blank']),
  21.                     new Email(['message' => 'form.email.not_email']),
  22.                 ],
  23.             ])
  24.         ;
  25.     }
  26.     public function configureOptions(OptionsResolver $resolver): void
  27.     {
  28.         $resolver->setDefaults([]);
  29.     }
  30. }