Password generator examples 

Include special characters 

Example: qe8)i2W1it-msR8

The password of the live stream with its generator

The password of the live stream with its generator

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',
);
Copied!

Only digits, length 8 (minimum length) 

Example: 28233371

The door code of a room uses the policy myExtensionDigits. The extension defines it in its ext_localconf.php, and its generator creates 8 digits:

EXT:my_extension/ext_localconf.php (excerpt)
<?php

use MyVendor\MyExtension\Controller\ConferenceController;
use MyVendor\MyExtension\Evaluation\AbstractEvaluation;
use MyVendor\MyExtension\Evaluation\HashtagEvaluation;
use MyVendor\MyExtension\Form\Element\BadgeNameElement;
use MyVendor\MyExtension\Form\FieldInformation\InformationText;
use MyVendor\MyExtension\Form\FieldInformation\TalkOrderInformation;
use MyVendor\MyExtension\Form\FieldWizard\ReferencesToThisRecordWizard;
use TYPO3\CMS\Core\PasswordPolicy\Generator\PasswordGenerator;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') or die();

ExtensionUtility::configurePlugin(
  'MyExtension',
  'ConferenceList',
  [ConferenceController::class => ['list', 'show']],
);

// Classes that TCA fields name in 'eval'
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][HashtagEvaluation::class] = '';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][AbstractEvaluation::class] = '';

// The information above the talks of a conference, see
// Configuration/TCA/Overrides/120-tx_myextension_conference-talks.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791234567] = [
  'nodeName' => 'talkOrderInformation',
  'priority' => 30,
  'class' => TalkOrderInformation::class,
];

// The badge name of a frontend user, see
// Configuration/TCA/Overrides/650-fe_users-tx_myextension_badge_name.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791300000] = [
  'nodeName' => 'badgeName',
  'priority' => 40,
  'class' => BadgeNameElement::class,
];

// The information text of fields, see for example
// Configuration/TCA/Overrides/310-tx_myextension_speaker-email.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791310000] = [
  'nodeName' => 'informationText',
  'priority' => 30,
  'class' => InformationText::class,
];

// The references to a conference above its form, see
// Configuration/TCA/Overrides/101-tx_myextension_conference-references.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791320000] = [
  'nodeName' => 'referencesToThisRecord',
  'priority' => 30,
  'class' => ReferencesToThisRecordWizard::class,
];

// The password policies of the password generators, see
// Configuration/TCA/Overrides/445-tx_myextension_location-door_code.php and
// Configuration/TCA/Overrides/345-tx_myextension_speaker-upload_token.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionDigits'] = [
  'generator' => [
    'className' => PasswordGenerator::class,
    'options' => [
      'length' => 8,
      'lowerCaseCharacters' => false,
      'upperCaseCharacters' => false,
      'digitCharacters' => true,
    ],
  ],
  'validators' => [],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionBase64'] = [
  'generator' => [
    'className' => PasswordGenerator::class,
    'options' => [
      'length' => 35,
      'random' => 'base64',
    ],
  ],
  'validators' => [],
];
Copied!
EXT:my_extension/Configuration/TCA/Overrides/445-tx_myextension_location-door_code.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

ExtensionManagementUtility::addTCAcolumns('tx_myextension_location', [
  'door_code' => [
    'label' => 'my_extension.db:location.door_code',
    'config' => [
      'type' => 'password',
      'hashed' => false,
      'fieldControl' => [
        'passwordGenerator' => [
          'renderType' => 'passwordGenerator',
          'options' => [
            // The keypad at the door of the room has only digits
            'passwordPolicy' => 'myExtensionDigits',
          ],
        ],
      ],
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_location',
  'door_code',
  '',
  'after:capacity',
);
Copied!

Hexadecimal random bytes, length 40 

Example: a3f1c9e07b5d4e2f8c6a1b0d9e7f3c5a2b4d6e8f

The secret of the ticket shop, generated as a hex string

The secret of the ticket shop, generated as a hex string

The secret of the ticket shop uses the policy secretToken of the Core. Its generator creates a random hex string with 40 characters:

EXT: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',
);
Copied!

Base64 random bytes, readonly 

Example: zrt8sJd6GiqUI_EFgjPiedOj--D0NbTVOJz

The token of the upload link of a speaker uses the policy myExtensionBase64 of the extension. Its generator creates a random base64 string with 35 characters, and the editors cannot change it:

EXT:my_extension/ext_localconf.php (excerpt)
<?php

use MyVendor\MyExtension\Controller\ConferenceController;
use MyVendor\MyExtension\Evaluation\AbstractEvaluation;
use MyVendor\MyExtension\Evaluation\HashtagEvaluation;
use MyVendor\MyExtension\Form\Element\BadgeNameElement;
use MyVendor\MyExtension\Form\FieldInformation\InformationText;
use MyVendor\MyExtension\Form\FieldInformation\TalkOrderInformation;
use MyVendor\MyExtension\Form\FieldWizard\ReferencesToThisRecordWizard;
use TYPO3\CMS\Core\PasswordPolicy\Generator\PasswordGenerator;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') or die();

ExtensionUtility::configurePlugin(
  'MyExtension',
  'ConferenceList',
  [ConferenceController::class => ['list', 'show']],
);

// Classes that TCA fields name in 'eval'
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][HashtagEvaluation::class] = '';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][AbstractEvaluation::class] = '';

// The information above the talks of a conference, see
// Configuration/TCA/Overrides/120-tx_myextension_conference-talks.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791234567] = [
  'nodeName' => 'talkOrderInformation',
  'priority' => 30,
  'class' => TalkOrderInformation::class,
];

// The badge name of a frontend user, see
// Configuration/TCA/Overrides/650-fe_users-tx_myextension_badge_name.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791300000] = [
  'nodeName' => 'badgeName',
  'priority' => 40,
  'class' => BadgeNameElement::class,
];

// The information text of fields, see for example
// Configuration/TCA/Overrides/310-tx_myextension_speaker-email.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791310000] = [
  'nodeName' => 'informationText',
  'priority' => 30,
  'class' => InformationText::class,
];

// The references to a conference above its form, see
// Configuration/TCA/Overrides/101-tx_myextension_conference-references.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791320000] = [
  'nodeName' => 'referencesToThisRecord',
  'priority' => 30,
  'class' => ReferencesToThisRecordWizard::class,
];

// The password policies of the password generators, see
// Configuration/TCA/Overrides/445-tx_myextension_location-door_code.php and
// Configuration/TCA/Overrides/345-tx_myextension_speaker-upload_token.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionDigits'] = [
  'generator' => [
    'className' => PasswordGenerator::class,
    'options' => [
      'length' => 8,
      'lowerCaseCharacters' => false,
      'upperCaseCharacters' => false,
      'digitCharacters' => true,
    ],
  ],
  'validators' => [],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionBase64'] = [
  'generator' => [
    'className' => PasswordGenerator::class,
    'options' => [
      'length' => 35,
      'random' => 'base64',
    ],
  ],
  'validators' => [],
];
Copied!
EXT:my_extension/Configuration/TCA/Overrides/345-tx_myextension_speaker-upload_token.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

ExtensionManagementUtility::addTCAcolumns('tx_myextension_speaker', [
  'upload_token' => [
    'label' => 'my_extension.db:speaker.upload_token',
    'config' => [
      'type' => 'password',
      'hashed' => false,
      'fieldControl' => [
        'passwordGenerator' => [
          'renderType' => 'passwordGenerator',
          'options' => [
            // The token is part of the link with which the speaker uploads
            // the slides, so the editors cannot choose it themselves
            'passwordPolicy' => 'myExtensionBase64',
            'allowEdit' => false,
          ],
        ],
      ],
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_speaker',
  'upload_token',
  '',
  'after:identifier',
);
Copied!

Properties 

Field control options 

title 

title
Type
String / localized string
Default
LLL:core.core:labels.generatePassword
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['title']

Define a title for the control button.

allowEdit 

allowEdit
Type
boolean
Default
true
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['allowEdit']

If set to false , the user cannot edit the generated password.

Password policy 

passwordPolicy
Type
string
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordPolicy']
Examples
Digits for a door code, Hex string for a secret, Base64 string for a token
Added
14.2

This option can be used to configure which Password policy should be used for the password field. Use the key of the policy as defined in $GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies'] .

The field control uses the generator section of the policy. If the option is missing, or the policy has no generator, the field shows no password generator.