src/Form/LoginType.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\EventListener\ReCaptchaValidationListener;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Psr\Log\LoggerInterface;
  6. use Symfony\Component\Form\AbstractType;
  7. use Gregwar\CaptchaBundle\Type\CaptchaType;
  8. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\Form\FormError;
  11. use Symfony\Component\Form\FormEvents;
  12. use Symfony\Component\Form\FormEvent;
  13. use Symfony\Component\HttpFoundation\RedirectResponse;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\OptionsResolver\OptionsResolver;
  16. use Symfony\Component\Routing\RouterInterface;
  17. use Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface;
  18. use Symfony\Component\HttpFoundation\RequestStack;
  19. use Symfony\Component\Security\Core\Security;
  20. use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
  21. class LoginType extends AbstractType
  22. {
  23.     /**
  24.      * Campos del formulario de login (Fase A UX).
  25.      */
  26.     public function buildForm(FormBuilderInterface $builder, array $options): void
  27.     {
  28.         $builder
  29.             ->add('_username', null, [
  30.                 'attr' => [
  31.                     'class' => 'form-control m-input form-control-input-login',
  32.                     'placeholder' => 'Usuario',
  33.                     'autocomplete' => 'username',
  34.                     'autofocus' => true,
  35.                 ],
  36.                 'label' => 'Usuario',
  37.                 'label_attr' => ['class' => 'col-lg-2 col-form-label'],
  38.                 'required' => true,
  39.             ])
  40.             ->add('_password', PasswordType::class, [
  41.                 'attr' => [
  42.                     'class' => 'form-control m-input m-login__form-input--last form-control-input-login',
  43.                     'placeholder' => 'Contraseña',
  44.                     'autocomplete' => 'current-password',
  45.                     'id' => 'login_password',
  46.                 ],
  47.                 'label' => 'Contraseña',
  48.                 'label_attr' => ['class' => 'col-lg-2 col-form-label'],
  49.                 'required' => true,
  50.             ])
  51.             ->add('captcha', CaptchaType::class, [
  52.                 'attr' => [
  53.                     'class' => 'form-control form-control-input-login',
  54.                     'placeholder' => 'Código CAPTCHA',
  55.                     'autocomplete' => 'off',
  56.                     'autocapitalize' => 'characters',
  57.                     'spellcheck' => 'false',
  58.                 ],
  59.             ])
  60.         ;
  61.     }
  62.     public function configureOptions(OptionsResolver $resolver): void
  63.     {
  64.         $resolver->setDefaults([
  65.             // Configure your form options here
  66.         ]);
  67.     }
  68. }