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_tables.sql 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:
'config' => [
'type' => 'password',
],
Example: A password field with password generator
The password of the live stream with its generator
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'livestream_password' => [
'label' => 'my_extension.db:conference.livestream_password',
'displayCond' => 'FIELD:event_format:IN:online,hybrid',
'config' => [
'type' => 'password',
'hashed' => false,
'passwordPolicy' => 'default',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'passwordPolicy' => 'default',
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'livestream_password',
'',
'after:stream_url',
);
For more options on generating passwords see Property passwordGenerator and the password generator examples.
Properties of the TCA column type password
| Name | Type | Scope |
|---|---|---|
| boolean | Proc. | |
| array | Display | |
| boolean | ||
| 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 |
-
-
- Type
- boolean
- Default
- false
- TCA 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 'behaviour' => [ 'allowLanguageSynchronization' => true, ],Copied!
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']
- Scope
- Display
- Added
- 15.0, Feature: #110851 - Copy a generated password to the clipboard
Has information about the appearance, namely:
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['copyToClipboard']
- Added
- 15.0, Feature: #110851 - Copy a generated password to the clipboard
Shows a button next to the input field. The button copies the password to the clipboard of the operating system.
The backend form shows a stored password only obfuscated, also when it is not hashed. The button therefore appears only when the field holds a new value: a password that is typed or generated. When the record is saved, the button is hidden again.
Enable the option for a generated password that editors cannot edit, see allowEdit. Editors cannot select the text of such a field, so the button is the only way to copy the password before the record is saved.
The generated secret of the ticket shop with a button to copy it
Example: Copy the generated secret of the ticket shopEXT:my_extension/Configuration/TCA/Overrides/134-tx_myextension_conference-ticketing_secret.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [ 'ticketing_secret' => [ 'label' => 'my_extension.db:conference.ticketing_secret', 'config' => [ 'type' => 'password', 'hashed' => false, 'appearance' => [ 'copyToClipboard' => true, ], 'fieldControl' => [ 'passwordGenerator' => [ 'renderType' => 'passwordGenerator', 'options' => [ 'passwordPolicy' => 'secretToken', 'allowEdit' => false, ], ], ], ], ], ]); ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_conference', 'ticketing_secret', '', 'after:prices', );
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['autocomplete']
- Scope
- Display
By default, the
autocomplete=new-attribute will be added to the resulting input field. Ifpassword autocomplete=trueis configured in TCA, aautocomplete=current-attribute will be added to the element.password 'autocomplete' => true,Copied!
-
- Type
- string
- TCA 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.
-
For details see fieldControl.
-
For details see fieldInformation.
-
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['defaultLanguageDifferences']
For details see defaultLanguageDifferences.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['localizationStateSelector']
For details see localizationStateSelector.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['otherLanguageContent']
For details see otherLanguageContent.
-
- Type
- boolean
- Default
- true
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['hashed']
- Scope
- Proc.
If
hashedis set tofalse, if the field value will be saved as plaintext to the database.Note
The configuration
'hashed' => falsehas 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
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'livestream_password' => [
'label' => 'my_extension.db:conference.livestream_password',
'displayCond' => 'FIELD:event_format:IN:online,hybrid',
'config' => [
'type' => 'password',
'hashed' => false,
'passwordPolicy' => 'default',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'passwordPolicy' => 'default',
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'livestream_password',
'',
'after:stream_url',
);
-
- Type
- string (keywords)
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['mode']
- Scope
- Display
Possible keywords:
useOr Override Placeholder This property is related to the
placeholderproperty. 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 propertynullablemust be set totrue.
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['nullable']
- 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
NULLin 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
NULLvalue.
'nullable' => true,
-
- Type
- boolean
- TCA 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.
The password of the live stream with a generated password
The same field after saving: the password is hidden
EXT:my_extension/Configuration/TCA/Overrides/119-tx_myextension_conference-livestream_password.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [ 'livestream_password' => [ 'label' => 'my_extension.db:conference.livestream_password', 'displayCond' => 'FIELD:event_format:IN:online,hybrid', 'config' => [ 'type' => 'password', 'hashed' => false, 'passwordPolicy' => 'default', 'fieldControl' => [ 'passwordGenerator' => [ 'renderType' => 'passwordGenerator', 'options' => [ 'passwordPolicy' => 'default', ], ], ], ], ], ]); ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_conference', 'livestream_password', '', 'after:stream_url', );
-
- Type
- string
- TCA 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: the password policy examples.
-
- Type
- string, hexadecimal password representation
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['placeholder']
- Scope
- Display
Placeholder, containing a hexadecimal password representation.
'placeholder' => 'Choose a password',Copied!
-
- Type
- boolean
- TCA 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.
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['required']
- Scope
- Display / Proc.
If set to true a non-empty value is required in the field. Otherwise the form cannot be saved.
-
- Type
- integer
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['size']
- 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.