[FEATURE] Add TCA autocomplete setting for input fields 83/43883/4
authorZsolt Molnar <zsolt.molnar@arxia.com>
Wed, 7 Oct 2015 10:55:05 +0000 (13:55 +0300)
committerBenni Mack <benni@typo3.org>
Thu, 8 Oct 2015 18:27:09 +0000 (20:27 +0200)
This patch adds an additional TCA configuration for input fields to
switch on or off auto completion. This is used for username and password
fields for frontend and backend users.

Resolves: #70126
Releases: master
Change-Id: I1bda9e19826ca975a4e3f56d3f67b82e898e8c2e
Reviewed-on: http://review.typo3.org/43883
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/Element/InputTextElement.php
typo3/sysext/core/Configuration/TCA/be_users.php
typo3/sysext/core/Documentation/Changelog/master/Feature-70126-IntroduceTcaOptionToAddAutocompleteAttributeToInputFields.rst [new file with mode: 0644]
typo3/sysext/frontend/Configuration/TCA/fe_users.php
typo3/sysext/rsaauth/Classes/Form/Element/RsaInputElement.php

index a526ece..9baeb0f 100644 (file)
@@ -184,6 +184,10 @@ class InputTextElement extends AbstractFormElement {
                        $attributes['placeholder'] = trim($config['placeholder']);
                }
 
+               if (isset($config['autocomplete'])) {
+                       $attributes['autocomplete'] = empty($config['autocomplete']) ? 'off' : 'on';
+               }
+
                // Build the attribute string
                $attributeString = '';
                foreach ($attributes as $attributeName => $attributeValue) {
index 0882578..ffb995c 100644 (file)
@@ -37,7 +37,8 @@ return array(
                                'type' => 'input',
                                'size' => '20',
                                'max' => '50',
-                               'eval' => 'nospace,trim,lower,unique,required'
+                               'eval' => 'nospace,trim,lower,unique,required',
+                               'autocomplete' => FALSE,
                        )
                ),
                'description' => array(
@@ -55,7 +56,8 @@ return array(
                                'type' => 'input',
                                'size' => '20',
                                'max' => '40',
-                               'eval' => 'trim,required,md5,password'
+                               'eval' => 'trim,required,md5,password',
+                               'autocomplete' => FALSE,
                        )
                ),
                'usergroup' => array(
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-70126-IntroduceTcaOptionToAddAutocompleteAttributeToInputFields.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-70126-IntroduceTcaOptionToAddAutocompleteAttributeToInputFields.rst
new file mode 100644 (file)
index 0000000..6cd1af2
--- /dev/null
@@ -0,0 +1,17 @@
+====================================================================================
+Feature: #70126 - Introduce TCA option to add autocomplete attribute to input fields
+====================================================================================
+
+Description
+===========
+
+It is now possible to enforce or disable the auto completion for input fields in edit mode.
+The option is called ``autocomplete`` and can be set to TRUE or FALSE in the config section of a field.
+
+Example
+-------
+
+.. code-block:: php
+
+       // Prevent auto completion of username field for be_users records
+       $GLOBALS['TCA']['be_users']['columns']['username']['config']['autocomplete'] = FALSE;
\ No newline at end of file
index 682152e..0b456ff 100644 (file)
@@ -30,7 +30,8 @@ return array(
                                'type' => 'input',
                                'size' => '20',
                                'max' => '255',
-                               'eval' => 'nospace,trim,lower,uniqueInPid,required'
+                               'eval' => 'nospace,trim,lower,uniqueInPid,required',
+                               'autocomplete' => FALSE,
                        )
                ),
                'password' => array(
@@ -39,7 +40,8 @@ return array(
                                'type' => 'input',
                                'size' => '10',
                                'max' => '40',
-                               'eval' => 'nospace,trim,required,password'
+                               'eval' => 'nospace,trim,required,password',
+                               'autocomplete' => FALSE,
                        )
                ),
                'usergroup' => array(
index 6d2693c..6ceba71 100644 (file)
@@ -72,6 +72,7 @@ class RsaInputElement extends AbstractFormElement {
                                case 'password':
                                        $attributes['type'] = 'password';
                                        $attributes['value'] = '********';
+                                       $attributes['autocomplete'] = 'off';
                                        break;
                                default:
                                        // @todo: This is ugly: The code should find out on it's own whether a eval definition is a
@@ -124,6 +125,10 @@ class RsaInputElement extends AbstractFormElement {
                        $attributes['placeholder'] = trim($config['placeholder']);
                }
 
+               if (isset($config['autocomplete'])) {
+                       $attributes['autocomplete'] = empty($config['autocomplete']) ? 'off' : 'on';
+               }
+
                // Build the attribute string
                $attributeString = '';
                foreach ($attributes as $attributeName => $attributeValue) {