From e0b3f6f5b1eee413e681c2482bca738fdf753f5f Mon Sep 17 00:00:00 2001 From: Midhun Devasia Date: Thu, 15 Dec 2016 16:35:47 +0530 Subject: [PATCH] [FEATURE] Add autocomplete attribute to TextfieldViewHelper This attribute indicates whether the value of the input field can be automatically completed by the browser based on the user inputs to similar fields. Possible values are: off: The user must explicitly enter a value for every use. on : The browser is allowed to automatically complete the value based on values that the user has entered during previous uses. Resolves: #78999 Releases: master Change-Id: I2bb1857d8454e3e93b948323f096c726d07f57cc --- .../ViewHelpers/Form/TextfieldViewHelper.php | 1 + .../ViewHelpers/Form/TextfieldViewHelperTest.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php index 95b8e23a..f2c42b6 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php @@ -52,6 +52,7 @@ class TextfieldViewHelper extends AbstractFormFieldViewHelper $this->registerTagAttribute('size', 'int', 'The size of the input field'); $this->registerTagAttribute('placeholder', 'string', 'The placeholder of the textfield'); $this->registerTagAttribute('pattern', 'string', 'HTML5 validation pattern'); + $this->registerTagAttribute('autocomplete', 'string', 'Browser should attempt to automatically complete the input based on user inputs'); $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', false, 'f3-form-error'); $this->registerUniversalTagAttributes(); $this->registerArgument('required', 'bool', 'If the field is required or not', false, false); diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextfieldViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextfieldViewHelperTest.php index 8e329fb..6c31ee4 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextfieldViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextfieldViewHelperTest.php @@ -130,4 +130,25 @@ class TextfieldViewHelperTest extends ViewHelperBaseTestcase $actualResult = $this->viewHelper->initializeArgumentsAndRender(); $this->assertEquals($expectedResult, $actualResult); } + + /** + * @test + */ + public function renderCorrectlySetsAutocompleteAttribute() + { + $this->setArgumentsUnderTest( + $this->viewHelper, + [ + 'name' => 'TextfieldName', + 'value' => 'TextfieldValue', + 'type' => 'text', + 'autocomplete' => 'off' + ] + ); + + $this->viewHelper->setViewHelperNode(new EmptySyntaxTreeNode()); + $expectedResult = ''; + $actualResult = $this->viewHelper->initializeArgumentsAndRender(); + $this->assertEquals($expectedResult, $actualResult); + } } -- 2.7.0