Add autocomplete attribute to HTML forms

Add autocomplete for email, name, username, current-password, new-password and one-time-code fields.
This commit is contained in:
Frédéric Guillot 2020-12-23 11:20:00 -08:00 committed by fguillot
parent dca39a7fb2
commit 050fe904ba
10 changed files with 28 additions and 28 deletions

View File

@ -12,10 +12,10 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'autocomplete="username"')) ?>
<?= $this->form->label(t('Password'), 'password') ?>
<?= $this->form->password('password', $values, $errors, array('required')) ?>
<?= $this->form->password('password', $values, $errors, array('required', 'autocomplete="current-password"')) ?>
<?php if (isset($captcha) && $captcha): ?>
<?= $this->form->label(t('Enter the text below'), 'captcha') ?>

View File

@ -4,10 +4,10 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('New password'), 'password') ?>
<?= $this->form->password('password', $values, $errors) ?>
<?= $this->form->password('password', $values, $errors, ['autocomplete="new-password"']) ?>
<?= $this->form->label(t('Confirmation'), 'confirmation') ?>
<?= $this->form->password('confirmation', $values, $errors) ?>
<?= $this->form->password('confirmation', $values, $errors, ['autocomplete="new-password"']) ?>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Change Password') ?></button>

View File

@ -4,7 +4,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'autocomplete="username"')) ?>
<p class="form-help"><?= t('Your profile must have a valid email address.') ?></p>
<?= $this->form->label(t('Enter the text below'), 'captcha') ?>

View File

@ -17,7 +17,7 @@
<?= $this->form->text('name', $values, $errors, array('required', 'autofocus', 'tabindex="1"')) ?>
<?= $this->form->label(t('Email'), 'email') ?>
<?= $this->form->email('email', $values, $errors, array('tabindex="2"')) ?>
<?= $this->form->email('email', $values, $errors, array('tabindex="2"', 'autocomplete="email"')) ?>
<p class="form-help"><?= t('The project email is optional and could be used by several plugins.') ?></p>
<?= $this->form->label(t('Identifier'), 'identifier') ?>

View File

@ -2,11 +2,11 @@
<div class="page-header">
<h2><?= t('Two factor authentication') ?></h2>
</div>
<form method="post" action="<?= $this->url->href('TwoFactorController', 'check', array('user_id' => $this->user->getId())) ?>" autocomplete="off">
<form method="post" action="<?= $this->url->href('TwoFactorController', 'check', array('user_id' => $this->user->getId())) ?>">
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Code'), 'code') ?>
<?= $this->form->text('code', array(), array(), array('placeholder="123456"', 'autofocus'), 'form-numeric') ?>
<?= $this->form->text('code', array(), array(), array('placeholder="123456"', 'autofocus', 'autocomplete="one-time-code"', 'pattern="[0-9]*"', 'inputmode="numeric"'), 'form-numeric') ?>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Check my code') ?></button>

View File

@ -21,11 +21,11 @@
<h3><?= t('Test your device') ?></h3>
<div class="panel">
<form method="post" action="<?= $this->url->href('TwoFactorController', 'test', array('user_id' => $user['id'])) ?>" autocomplete="off">
<form method="post" action="<?= $this->url->href('TwoFactorController', 'test', array('user_id' => $user['id'])) ?>">
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Code'), 'code') ?>
<?= $this->form->text('code', array(), array(), array('placeholder="123456"', 'autofocus'), 'form-numeric') ?>
<?= $this->form->text('code', array(), array(), array('placeholder="123456"', 'autofocus'), 'form-numeric', 'autocomplete="one-time-code"', 'pattern="[0-9]*"', 'inputmode="numeric"') ?>
<?= $this->modal->submitButtons(array('submitLabel' => t('Check my code'))) ?>
</form>

View File

@ -1,7 +1,7 @@
<div class="page-header">
<h2><?= t('New User') ?></h2>
</div>
<form method="post" action="<?= $this->url->href('UserCreationController', 'save') ?>" autocomplete="off">
<form method="post" action="<?= $this->url->href('UserCreationController', 'save') ?>">
<?= $this->form->csrf() ?>
<div class="form-columns">
@ -10,13 +10,13 @@
<legend><?= t('Profile') ?></legend>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="191"', 'autocomplete="username"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors) ?>
<?= $this->form->text('name', $values, $errors, ['autocomplete="name"']) ?>
<?= $this->form->label(t('Email'), 'email') ?>
<?= $this->form->email('email', $values, $errors) ?>
<?= $this->form->email('email', $values, $errors, ['autocomplete="email"']) ?>
</fieldset>
<fieldset>
@ -25,7 +25,7 @@
<p class="form-help"><?= t('If checked, this user will use a third-party system for authentication.') ?></p>
<?= $this->form->label(t('Password'), 'password') ?>
<?= $this->form->password('password', $values, $errors) ?>
<?= $this->form->password('password', $values, $errors, ['autocomplete="new-password"']) ?>
<p class="form-help"><?= t('The password is necessary only for local users.') ?></p>
<?= $this->form->label(t('Confirmation'), 'confirmation') ?>

View File

@ -2,16 +2,16 @@
<h2><?= t('Password modification') ?></h2>
</div>
<form method="post" action="<?= $this->url->href('UserCredentialController', 'savePassword', array('user_id' => $user['id'])) ?>" autocomplete="off">
<form method="post" action="<?= $this->url->href('UserCredentialController', 'savePassword', array('user_id' => $user['id'])) ?>">
<?= $this->form->hidden('id', $values) ?>
<?= $this->form->csrf() ?>
<fieldset>
<?= $this->form->label(t('Current password for the user "%s"', $this->user->getFullname()), 'current_password') ?>
<?= $this->form->password('current_password', $values, $errors, array('autofocus')) ?>
<?= $this->form->password('current_password', $values, $errors, array('autofocus', 'autocomplete="current-password"')) ?>
<?= $this->form->label(t('New password for the user "%s"', $this->user->getFullname($user)), 'password') ?>
<?= $this->form->password('password', $values, $errors) ?>
<?= $this->form->password('password', $values, $errors, ['autocomplete="new-password"']) ?>
<?= $this->form->label(t('Confirmation'), 'confirmation') ?>
<?= $this->form->password('confirmation', $values, $errors) ?>

View File

@ -2,29 +2,29 @@
<div class="page-header">
<h2><?= t('Sign-up') ?></h2>
</div>
<form method="post" action="<?= $this->url->href('UserInviteController', 'register', array('token' => $token)) ?>" autocomplete="off">
<form method="post" action="<?= $this->url->href('UserInviteController', 'register', array('token' => $token)) ?>">
<?= $this->form->csrf() ?>
<fieldset>
<legend><?= t('Profile') ?></legend>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="191"', 'autocomplete="username"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors) ?>
<?= $this->form->text('name', $values, $errors, ['autocomplete="name"']) ?>
<?= $this->form->label(t('Email'), 'email') ?>
<?= $this->form->email('email', $values, $errors, array('required')) ?>
<?= $this->form->email('email', $values, $errors, array('required', 'autocomplete="email"')) ?>
</fieldset>
<fieldset>
<legend><?= t('Credentials') ?></legend>
<?= $this->form->label(t('Password'), 'password') ?>
<?= $this->form->password('password', $values, $errors, array('required')) ?>
<?= $this->form->password('password', $values, $errors, array('required', 'autocomplete="new-password"')) ?>
<?= $this->form->label(t('Confirmation'), 'confirmation') ?>
<?= $this->form->password('confirmation', $values, $errors, array('required')) ?>
<?= $this->form->password('confirmation', $values, $errors, array('required', 'autocomplete="new-password"')) ?>
</fieldset>
<fieldset>

View File

@ -1,20 +1,20 @@
<div class="page-header">
<h2><?= t('Edit user') ?></h2>
</div>
<form method="post" action="<?= $this->url->href('UserModificationController', 'save', array('user_id' => $user['id'])) ?>" autocomplete="off">
<form method="post" action="<?= $this->url->href('UserModificationController', 'save', array('user_id' => $user['id'])) ?>">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('id', $values) ?>
<fieldset>
<legend><?= t('Profile') ?></legend>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 && !$this->user->isAdmin() ? 'readonly' : '', 'maxlength="191"')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'autocomplete="username"', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 && !$this->user->isAdmin() ? 'readonly' : '', 'maxlength="191"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array($this->user->hasAccess('UserModificationController', 'show/edit_name') ? '' : 'readonly')) ?>
<?= $this->form->text('name', $values, $errors, array($this->user->hasAccess('UserModificationController', 'show/edit_name') ? 'autocomplete="name"' : 'readonly')) ?>
<?= $this->form->label(t('Email'), 'email') ?>
<?= $this->form->email('email', $values, $errors, array($this->user->hasAccess('UserModificationController', 'show/edit_email') ? '' : 'readonly')) ?>
<?= $this->form->email('email', $values, $errors, array($this->user->hasAccess('UserModificationController', 'show/edit_email') ? 'autocomplete="email"' : 'readonly')) ?>
</fieldset>
<fieldset>