src/Form/LoginFormType.php line 41

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. declare(strict_types=1);
  15. /**
  16.  * Pimcore
  17.  *
  18.  * This source file is available under two different licenses:
  19.  * - GNU General Public License version 3 (GPLv3)
  20.  * - Pimcore Enterprise License (PEL)
  21.  * Full copyright and license information is available in
  22.  * LICENSE.md which is distributed with this source code.
  23.  *
  24.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  25.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  26.  */
  27. namespace App\Form;
  28. use Symfony\Component\Form\AbstractType;
  29. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  30. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  31. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  32. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  33. use Symfony\Component\Form\FormBuilderInterface;
  34. use Symfony\Component\OptionsResolver\OptionsResolver;
  35. use Symfony\Component\PasswordHasher\PasswordHasherInterface;
  36. class LoginFormType extends AbstractType
  37. {
  38.     /**
  39.      * @inheritDoc
  40.      */
  41.     public function buildForm(FormBuilderInterface $builder, array $options)
  42.     {
  43.         $builder
  44.             ->add('_username'EmailType::class, [
  45.                 'label' => 'user.email',
  46.                 'label_attr' => [
  47.                     'class' => 'sr-only'
  48.                 ]
  49.             ])
  50.             ->add('_password'PasswordType::class, [
  51.                 'label' => 'user.password',
  52.                 'label_attr' => [
  53.                     'class' => 'sr-only'
  54.                 ],
  55.                 'attr' => [
  56.                     'maxlength' => PasswordHasherInterface::MAX_PASSWORD_LENGTH
  57.                 ]
  58.             ])
  59.             ->add('_target_path'HiddenType::class)
  60.             ->add('_submit'SubmitType::class, [
  61.                 'label' => 'general.login'
  62.             ]);
  63.     }
  64.     /**
  65.      * @inheritDoc
  66.      */
  67.     public function getBlockPrefix()
  68.     {
  69.         // we need to set this to an empty string as we want _username as input name
  70.         // instead of login_form[_username] to work with the form authenticator out
  71.         // of the box
  72.         return '';
  73.     }
  74.     /**
  75.      * @inheritDoc
  76.      */
  77.     public function configureOptions(OptionsResolver $resolver)
  78.     {
  79.     }
  80. }