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.     /**
  18.      * {@inheritdoc}
  19.      */
  20.     public function buildView(FormView $viewFormInterface $form, array $options)
  21.     {
  22.         if ($options['always_empty'] || !$form->isSubmitted()) {
  23.             $view->vars['value'] = '';
  24.         }
  25.     }
  26.     /**
  27.      * {@inheritdoc}
  28.      */
  29.     public function configureOptions(OptionsResolver $resolver)
  30.     {
  31.         $resolver->setDefaults([
  32.             'always_empty' => true,
  33.             'trim' => false,
  34.             'invalid_message' => 'The password is invalid.',
  35.         ]);
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function getParent(): ?string
  41.     {
  42.         return TextType::class;
  43.     }
  44.     /**
  45.      * {@inheritdoc}
  46.      */
  47.     public function getBlockPrefix(): string
  48.     {
  49.         return 'password';
  50.     }
  51. }