Password
New in version 12.0
The TCA type password
has been introduced. It replaces the
eval=password
and eval=salted
option of
TCA type input
.
The TCA type password
should be used for input values that represent
passwords.
Table of Contents
Example: A basic password field:
[
'columns' => [
'password_1' => [
'label' => 'password_1',
'description' => 'type=password',
'config' => [
'type' => 'password',
],
],
],
]
Example: A password field with password generator
[
'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,
],
],
],
],
],
],
],
]
For more options on generating passwords see Property passwordGenerator and Password generator examples.
Properties of the TCA column type password
behaviour
-
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_
. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.state
autocomplete
-
- Type
- boolean
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Display
- Default
- false
By default, the
autocomplete=new-
attribute will be added to the resulting input field. Ifpassword autocomplete=true
is configured in TCA, aautocomplete=current-
attribute will be added to the element.password
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
-
For details see fieldControl.
fieldInformation
-
For details see fieldInformation.
fieldWizard
-
defaultLanguageDifferences
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['defaultLanguageDifferences']
For details see defaultLanguageDifferences.
localizationStateSelector
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['localizationStateSelector']
For details see localizationStateSelector.
otherLanguageContent
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['otherLanguageContent']
For details see otherLanguageContent.
hashed
-
- Type
- boolean
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Proc.
- Default
- true
If
hashed
is set tofalse
, if the field value will be saved as plaintext to the database.Note
The configuration
'hashed' => false
has no effect for all fields in the tablesbe_
andusers fe_
. In general it is not recommended to save passwords as plain text to the database.users
[
'columns' => [
'password_2' => [
'label' => 'password_2',
'description' => 'type=password hashed=false',
'config' => [
'type' => 'password',
'hashed' => false,
],
],
],
]
mode
-
- Type
- string (keywords)
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['mode']
- Scope
- Display
Possible keywords:
use
Or Override Placeholder 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 beNULL
.Warning
In order for this property to apply properly, the DB column must be allowed to be
NULL
, and propertynullable
must be set totrue
.
Changed in version 12.0
This option was introduced to replace the TCA eval
option with
null
as value.
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 aNULL
.The database field must allow the
NULL
value.
<?php
$passwordField = [
'config' => [
'title' => 'A nullable field',
'config' => [
'type' => 'password',
'nullable' => true,
],
],
];
New in version 12.1
passwordGenerator
-
- Type
- boolean
- Path
$GLOBALS
['TCA'] [$table] ['columns'] [$field] ['config'] ['field Control'] ['password Generator'] - 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.
New in version 12.3
passwordPolicy
-
- Type
- string
- Path
$GLOBALS
['TCA'] [$table] ['columns'] [$field] ['config'] ['field Control'] ['password Policy'] - 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
-
- Type
- string, hexadecimal password representation
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['placeholder']
- Scope
- Display
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.
Warning
This property affects only the display. It is still possible to write to those fields when using the DataHandler.
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
-
- 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='salted
to
type=password
is done like following:
'password_field' => [
'label' => 'Password',
'config' => [
- 'type' => 'input',
- 'eval' => 'trim,password,saltedPassword',
+ 'type' => 'password',
],
],
'password_field' => [
'label' => 'Password',
'config' => [
- 'type' => 'input',
- 'eval' => 'trim,password',
+ 'type' => 'password',
+ 'hashed' => false,
],
],
An automatic TCA migration is performed on the fly, migrating all occurrences
to the new TCA type and triggering a PHP E_
error
where code adoption has to take place.
Note
The value of TCA type password
column is automatically trimmed before
being stored (and optionally hashed) in the database. Therefore, the eval=trim
option is no longer needed and should be removed from the TCA configuration.