From 9ad2cb5e669d8df3ac534fcf3902d87da334dcd2 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Wed, 4 Aug 2021 20:08:28 +0000 Subject: [PATCH] [UTIL][FormFields] Allow specifying whether a password is required and provide placeholder text --- src/Util/FormFields.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Util/FormFields.php b/src/Util/FormFields.php index 584fd8ff58..96cb2ff36d 100644 --- a/src/Util/FormFields.php +++ b/src/Util/FormFields.php @@ -10,12 +10,14 @@ use Symfony\Component\Validator\Constraints\NotBlank; abstract class FormFields { - public static function repeated_password() + public static function repeated_password(array $options = []): array { return ['password', RepeatedType::class, ['type' => PasswordType::class, 'first_options' => [ 'label' => _m('Password'), + 'attr' => ['placeholder' => '********'], + 'required' => $options['required'] ?? true, 'constraints' => [ new NotBlank(['message' => _m('Please enter a password')]), new Length(['min' => Common::config('password', 'min_length'), 'minMessage' => _m(['Your password should be at least # characters'], ['count' => Common::config('password', 'min_length')]), @@ -24,6 +26,7 @@ abstract class FormFields ], 'second_options' => [ 'label' => _m('Repeat Password'), + 'attr' => ['placeholder' => '********'], ], 'mapped' => false, 'invalid_message' => _m('The password fields must match'), @@ -31,10 +34,12 @@ abstract class FormFields ]; } - public static function password() + public static function password(array $options = []): array { ['password', PasswordType::class, [ 'label' => _m('Password'), + 'attr' => ['placeholder' => '********'], + 'required' => $options['required'] ?? true, 'mapped' => false, 'constraints' => [ new NotBlank(['message' => _m('Please enter a password')]),