vendor/symfony/form/Extension/Core/Type/PasswordType.php line 19

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Form\Extension\Core\Type;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\Form\FormInterface;
  13. use Symfony\Component\Form\FormView;
  14. use Symfony\Component\OptionsResolver\OptionsResolver;
  15. class PasswordType extends AbstractType
  16. {
  17.     public function buildView(FormView $viewFormInterface $form, array $options)
  18.     {
  19.         if ($options['always_empty'] || !$form->isSubmitted()) {
  20.             $view->vars['value'] = '';
  21.         }
  22.     }
  23.     public function configureOptions(OptionsResolver $resolver)
  24.     {
  25.         $resolver->setDefaults([
  26.             'always_empty' => true,
  27.             'trim' => false,
  28.             'invalid_message' => 'The password is invalid.',
  29.         ]);
  30.     }
  31.     public function getParent(): ?string
  32.     {
  33.         return TextType::class;
  34.     }
  35.     public function getBlockPrefix(): string
  36.     {
  37.         return 'password';
  38.     }
  39. }