Skip to content

Commit 855084a

Browse files
Willem Stuursma-RuwenXWB
authored andcommitted
Add autocomplete hints for password inputs (#2661)
* Add autocomplete attributes to password inputs. https://www.chromium.org/developers/design-documents/form-styles-that-chromium-understands * Update composer.json to autoload tests. * Add autocomplete hints to login form too * checkstyle changes
1 parent a92d681 commit 855084a

6 files changed

Lines changed: 31 additions & 5 deletions

File tree

Form/Type/ChangePasswordFormType.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5555
new NotBlank(),
5656
new UserPassword($constraintsOptions),
5757
),
58+
'attr' => array(
59+
'autcomplete' => 'current-password',
60+
),
5861
));
5962

6063
$builder->add('plainPassword', RepeatedType::class, array(
6164
'type' => PasswordType::class,
62-
'options' => array('translation_domain' => 'FOSUserBundle'),
65+
'options' => array(
66+
'translation_domain' => 'FOSUserBundle',
67+
'attr' => array(
68+
'autcomplete' => 'new-password',
69+
),
70+
),
6371
'first_options' => array('label' => 'form.new_password'),
6472
'second_options' => array('label' => 'form.new_password_confirmation'),
6573
'invalid_message' => 'fos_user.password.mismatch',

Form/Type/ProfileFormType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5757
new NotBlank(),
5858
new UserPassword($constraintsOptions),
5959
),
60+
'attr' => array(
61+
'autocomplete' => 'current-password',
62+
),
6063
));
6164
}
6265

Form/Type/RegistrationFormType.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4343
->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))
4444
->add('plainPassword', RepeatedType::class, array(
4545
'type' => PasswordType::class,
46-
'options' => array('translation_domain' => 'FOSUserBundle'),
46+
'options' => array(
47+
'translation_domain' => 'FOSUserBundle',
48+
'attr' => array(
49+
'autocomplete' => 'new-password',
50+
),
51+
),
4752
'first_options' => array('label' => 'form.password'),
4853
'second_options' => array('label' => 'form.password_confirmation'),
4954
'invalid_message' => 'fos_user.password.mismatch',

Form/Type/ResettingFormType.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3939
{
4040
$builder->add('plainPassword', RepeatedType::class, array(
4141
'type' => PasswordType::class,
42-
'options' => array('translation_domain' => 'FOSUserBundle'),
42+
'options' => array(
43+
'translation_domain' => 'FOSUserBundle',
44+
'attr' => array(
45+
'autocomplete' => 'new-password',
46+
),
47+
),
4348
'first_options' => array('label' => 'form.new_password'),
4449
'second_options' => array('label' => 'form.new_password_confirmation'),
4550
'invalid_message' => 'fos_user.password.mismatch',

Resources/views/Security/login_content.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
{% endif %}
1111

1212
<label for="username">{{ 'security.login.username'|trans }}</label>
13-
<input type="text" id="username" name="_username" value="{{ last_username }}" required="required" />
13+
<input type="text" id="username" name="_username" value="{{ last_username }}" required="required" autocomplete="username" />
1414

1515
<label for="password">{{ 'security.login.password'|trans }}</label>
16-
<input type="password" id="password" name="_password" required="required" />
16+
<input type="password" id="password" name="_password" required="required" autocomplete="current-password" />
1717

1818
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
1919
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
"/Tests/"
5151
]
5252
},
53+
"autoload-dev": {
54+
"psr-4": {
55+
"FOS\\UserBundle\\Tests\\": "/Tests/"
56+
}
57+
},
5358
"extra": {
5459
"branch-alias": {
5560
"dev-master": "2.1.x-dev"

0 commit comments

Comments
 (0)