Commit 367424f3 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Christian Kuhn
Browse files

[FEATURE] Add autocomplete attribute to PasswordViewHelper

The PasswordViewHelper is extended for a new tag
attribute "autocomplete", which can be used to
instruct the users' password manager how to fill
the password field.

Resolves: #94653
Releases: master
Change-Id: I00941f3bb61624d405dcdd8a6af48777c3364d1b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70121

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent c975426b
.. include:: ../../Includes.txt
===============================================================
Feature: #94653 - Autocomplete attribute for PasswordViewHelper
===============================================================
See :issue:`94653`
Description
===========
Since password managers are frequently used by end users nowadays,
a password field can define the :html:`autocomplete` attribute,
which informs the users' password manager how to fill the corresponding
field. For example, creating a new password or filling in the current password.
See `MDN Allowing autocomplete`_ for a full list of possible attribute values.
To ease the use for integrators and developers, the attribute can now
directly be added as tag attribute to the :php:`PasswordViewHelper`.
Example:
.. code-block:: html
<f:form.password name="newPassword" value="" autocomplete="new-password" />
<!-- Output -->
<input type="password" name="myNewPassword" value="" autocomplete="new-password" />
Impact
======
It's now possible to specify the `autocomplete` attribute for the password
field through the :php:`PasswordViewHelper`.
.. _MDN Allowing autocomplete: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password#allowing_autocomplete
.. index:: Fluid, ext:fluid
......@@ -15,13 +15,13 @@
<div>
<label>
<f:translate key="newpassword_label1"/>
<f:form.password name="newPass" additionalAttributes="{autocomplete: 'new-password'}"/>
<f:form.password name="newPass" autocomplete="new-password"/>
</label>
</div>
<div>
<label>
<f:translate key="newpassword_label2"/>
<f:form.password name="newPassRepeat" additionalAttributes="{autocomplete: 'new-password'}"/>
<f:form.password name="newPassRepeat" autocomplete="new-password"/>
</label>
</div>
<f:form.hidden name="hash" value="{hash}"/>
......
......@@ -54,6 +54,7 @@ class PasswordViewHelper extends AbstractFormFieldViewHelper
);
$this->registerTagAttribute('placeholder', 'string', 'The placeholder of the textfield');
$this->registerTagAttribute('readonly', 'string', 'The readonly attribute of the input field');
$this->registerTagAttribute('autocomplete', 'string', 'Specify the autocomplete behaviour for password managers');
$this->registerTagAttribute('size', 'int', 'The size of the input field');
$this->registerArgument(
'errorClass',
......
......@@ -25,7 +25,7 @@ class PasswordViewHelperTest extends FunctionalTestCase
/**
* @test
*/
public function renderCorrectlySetsTagName()
public function renderCorrectlySetsTagName(): void
{
$view = new StandaloneView();
$view->setTemplateSource('<f:form.password />');
......@@ -35,10 +35,20 @@ class PasswordViewHelperTest extends FunctionalTestCase
/**
* @test
*/
public function renderCorrectlySetsTypeNameAndValueAttributes()
public function renderCorrectlySetsTypeNameAndValueAttributes(): void
{
$view = new StandaloneView();
$view->setTemplateSource('<f:form.password name="NameOfTextbox" value="Current value" />');
self::assertSame('<input type="password" name="NameOfTextbox" value="Current value" />', $view->render());
}
/**
* @test
*/
public function renderCorrectlySetsAutocompleteTagAttribute(): void
{
$view = new StandaloneView();
$view->setTemplateSource('<f:form.password name="myNewPassword" value="" autocomplete="new-password" />');
self::assertSame('<input autocomplete="new-password" type="password" name="myNewPassword" value="" />', $view->render());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment