[FORM][FormFields] Add way of specifying attributes for password fields (namely form autocomplete=new-password)

This commit is contained in:
Hugo Sales 2021-11-20 21:27:00 +00:00 committed by Diogo Peralta Cordeiro
parent 3a5e52ee0d
commit 206856e1ba
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -33,14 +33,14 @@ abstract class FormFields
'first_options' => [ 'first_options' => [
'label' => _m('Password'), 'label' => _m('Password'),
'label_attr' => ['class' => 'section-form-label'], 'label_attr' => ['class' => 'section-form-label'],
'attr' => ['placeholder' => _m('********'), 'required' => $options['required'] ?? true], 'attr' => array_merge(['placeholder' => _m('********'), 'required' => $options['required'] ?? true], $options['attr'] ?? []),
'constraints' => $constraints, 'constraints' => $constraints,
'help' => _m('Write a password with at least {min_length} characters, and a maximum of {max_length}.', ['min_length' => Common::config('password', 'min_length'), 'max_length' => Common::config('password', 'max_length')]), 'help' => _m('Write a password with at least {min_length} characters, and a maximum of {max_length}.', ['min_length' => Common::config('password', 'min_length'), 'max_length' => Common::config('password', 'max_length')]),
], ],
'second_options' => [ 'second_options' => [
'label' => _m('Repeat Password'), 'label' => _m('Repeat Password'),
'label_attr' => ['class' => 'section-form-label'], 'label_attr' => ['class' => 'section-form-label'],
'attr' => ['placeholder' => _m('********')], 'attr' => array_merge(['placeholder' => _m('********'), 'required' => $options['required'] ?? true], $options['attr'] ?? []),
'help' => _m('Confirm your password.'), 'help' => _m('Confirm your password.'),
'required' => $options['required'] ?? true, 'required' => $options['required'] ?? true,
'constraints' => $constraints, 'constraints' => $constraints,
@ -61,7 +61,7 @@ abstract class FormFields
'password', PasswordType::class, [ 'password', PasswordType::class, [
'label' => _m('Password'), 'label' => _m('Password'),
'label_attr' => ['class' => 'section-form-label'], 'label_attr' => ['class' => 'section-form-label'],
'attr' => ['placeholder' => '********'], 'attr' => ['placeholder' => '********', 'autocomplete' => 'current-password'],
'required' => $options['required'] ?? true, 'required' => $options['required'] ?? true,
'mapped' => false, 'mapped' => false,
'constraints' => [ 'constraints' => [