Password

New in version 12.0

The TCA type password has been introduced. It replaces the eval=password and eval=saltedPassword option of TCA type input.

The TCA type password should be used for input values that represent passwords.

Example: A basic password field:

EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'password_1' => [
            'label' => 'password_1',
            'description' => 'type=password',
            'config' => [
                'type' => 'password',
            ],
        ],
    ],
]
Copied!

Example: A password field with password generator

A password generator using special chars.

A password generator using special chars.

EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'password_6' => [
            'label' => 'password_6',
            'description' => 'type=password fieldControl=passwordGenerator - all character sets',
            'config' => [
                'type' => 'password',
                'fieldControl' => [
                    'passwordGenerator' => [
                        'renderType' => 'passwordGenerator',
                        'options' => [
                            'title' => 'Create random password',
                            'passwordRules' => [
                                'specialCharacters' => true,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
]
Copied!

For more options on generating passwords see Property passwordGenerator and Password generator examples.

Properties of the TCA column type password

Name Type Scope
boolean Proc.
boolean Display
string Display / Proc.
array
array
array
boolean Proc.
string (keywords) Display
boolean Proc
boolean Display
string Display, Proc.
string, hexadecimal password representation Display
boolean Display
boolean Display / Proc.
integer Display

behaviour

behaviour

allowLanguageSynchronization

allowLanguageSynchronization
Type
boolean
Default
false
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['behaviour']['allowLanguageSynchronization']
Scope
Proc.

Allows an editor to select in a localized record whether the value is copied over from default or source language record, or if the field has an own value in the localization. If set to true and if the table supports localization and if a localized record is edited, this setting enables FieldWizard LocalizationStateSelector: Two or three radio buttons shown below the field input. The state of this is stored in a json encoded array in the database table called l10n_state. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.

EXT:my_extension/Configuration/TCA/Overrides/someTable.php
<?php

$passwordField = [
    'config' => [
        'type' => 'password',
        'behaviour' => [
            'allowLanguageSynchronization' => true,
        ],
    ],
];
Copied!

autocomplete

autocomplete
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display
Default
false

By default, the autocomplete=new-password attribute will be added to the resulting input field. If autocomplete=true is configured in TCA, a autocomplete=current-password attribute will be added to the element.

<?php

$passwordField = [
    'config' => [
        'label' => 'Your Password',
        'config' => [
            'type' => 'password',
            'size' => 20,
            'autocomplete' => true,
        ],
    ],
];
Copied!

default

default
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['default']
Scope
Display / Proc.

Default value set if a new record is created. If empty, no password gets selected.

fieldControl

fieldControl

For details see fieldControl.

fieldInformation

fieldInformation

For details see fieldInformation.

fieldWizard

fieldWizard

defaultLanguageDifferences

defaultLanguageDifferences
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['defaultLanguageDifferences']

For details see defaultLanguageDifferences.

localizationStateSelector

localizationStateSelector
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['localizationStateSelector']

For details see localizationStateSelector.

otherLanguageContent

otherLanguageContent
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['otherLanguageContent']

For details see otherLanguageContent.

hashed

hashed
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Proc.
Default
true

If hashed is set to false, if the field value will be saved as plaintext to the database.

Example: The password will be saved as plain text:
EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'password_2' => [
            'label' => 'password_2',
            'description' => 'type=password hashed=false',
            'config' => [
                'type' => 'password',
                'hashed' => false,
            ],
        ],
    ],
]
Copied!

mode

mode
Type
string (keywords)
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['mode']
Scope
Display

Possible keywords: useOrOverridePlaceholder

This property is related to the placeholder property. When defined, a checkbox will appear above the field. If that box is checked, the field can be used to enter whatever the user wants as usual. If the box is not checked, the field becomes read-only and the value saved to the database will be NULL.

Changed in version 12.0

This option was introduced to replace the TCA eval option with null as value.

nullable

nullable
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Default
false
Scope
Proc

If set to true, a checkbox will appear, which by default deactivates the field. In the deactivated state the field is saved as NULL in the database. By activating the checkbox it is possible to set a value. If nothing is entered into the field, then an empty string will be saved and not a NULL.

The database field must allow the NULL value.

Example: A nullable password field
<?php

$passwordField = [
    'config' => [
        'title' => 'A nullable field',
        'config' => [
            'type' => 'password',
            'nullable' => true,
        ],
    ],
];
Copied!

New in version 12.1

passwordGenerator

passwordGenerator
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']
Scope
Display

The control renders a button next to the password field allowing the user to generate a random password based on defined rules.

Using the control adds the generated password to the corresponding field. The password is visible to the backend user only once and stored encrypted in the database. Integrators are also able to define whether the user is allowed to edit the generated password before saving.

A basic password generator

A basic password generator

The same field as above after saving - the password is not displayed anymore

The same field as above after saving - the password is not displayed anymore

EXT:my_extension/Configuration/TCA/Overrides/tx_myextension_table.php
<?php

$GLOBALS['TCA']['tx_myextension_table']['columns']['password_field'] = [
    'label' => 'Password',
    'config' => [
        'type' => 'password',
        'fieldControl' => [
            'passwordGenerator' => [
                'renderType' => 'passwordGenerator',
            ],
        ],
    ],
];
Copied!

New in version 12.3

passwordPolicy

passwordPolicy
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordPolicy']
Scope
Display, Proc.

This option assigns a password policy to fields of the type password. For configured fields, the password policy validator will be used in DataHandler to ensure, that the new password complies with the configured password policy.

Password policy requirements are shown below the password field, when the focus is changed to the password field.

See also: Examples for using different password policies in TCA.

placeholder

placeholder
Type
string, hexadecimal password representation
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['placeholder']
Scope
Display

Placeholder, containing a hexadecimal password representation.

<?php

$temporaryColumns['aColorField'] = [
    'title' => 'My color field',
    'config' => [
        'type' => 'color',
        'placeholder' => '#FF8700',
        'mode' => 'useOrOverridePlaceholder',
    ],
];
Copied!

readOnly

readOnly
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['readOnly']
Scope
Display

Renders the field in a way that the user can see the value but cannot edit it.

required

required
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display / Proc.
Default
false

If set to true a non-empty value is required in the field. Otherwise the form cannot be saved.

size

size
Type
integer
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display

Abstract value for the width of the <input> field. To set the password field to the full width of the form area, use the value 50. Minimum is 10. Default is 30.

Migration: From eval='password' to type="password"

The migration from eval='password' and eval='saltedPassword' to type=password is done like following:

Migration of a password field with saltedPassword
  'password_field' => [
      'label' => 'Password',
      'config' => [
-         'type' => 'input',
-         'eval' => 'trim,password,saltedPassword',
+         'type' => 'password',
      ],
  ],
Copied!
Migration of a non-hashed password field
  'password_field' => [
      'label' => 'Password',
      'config' => [
-         'type' => 'input',
-         'eval' => 'trim,password',
+         'type' => 'password',
+         'hashed' => false,
      ],
  ],
  
Copied!

An automatic TCA migration is performed on the fly, migrating all occurrences to the new TCA type and triggering a PHP E_USER_DEPRECATED error where code adoption has to take place.