Password
New in version 13.0
When using the password
type, TYPO3 takes care of
generating the according database field.
A developer does not need to define this field in an extension's
ext_
file.
The TCA type password
should be used for input values that represent
passwords.
The according database field is generated automatically.
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
.
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,
],
],
];
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.
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.