src/Form/UserManagement/UserEmailType.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\UserManagement;
  4. use App\Validator\UserManagement\RegisteredUser;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Validator\Constraints\Length;
  10. final class UserEmailType extends AbstractType
  11. {
  12.     /**
  13.      * {@inheritdoc}
  14.      */
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $builder
  18.             ->add('email'EmailType::class, [
  19.                 'attr' => [
  20.                     'placeholder' => 'placeholder.enter_email',
  21.                 ],
  22.                 'label' => 'label.email',
  23.                 'constraints' => [new Length(['min' => 5]), new RegisteredUser()],
  24.             ]);
  25.     }
  26.     /**
  27.      * {@inheritdoc}
  28.      */
  29.     public function configureOptions(OptionsResolver $resolver): void
  30.     {
  31.         $resolver->setDefaults([]);
  32.     }
  33. }