addRecord
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['addRecord']
- Scope
- Display
- Types
- group
Control button to directly add a related record. Leaves the current view and opens a new form to add a new record. On 'Save and close', the record is directly selected as referenced element in the
type='group'field. If multiple tables are allowed, the first table from the allowed list is selected, if no specifictableoption is given.Note
The add record control is disabled by default, enable it if needed. It is shown below the
edit popupcontrol if not changed bybeloworaftersettings.
Examples
Select field
The speakers of a conference with field controls
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'speakers' => [
'label' => 'my_extension.db:conference.speakers',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_myextension_speaker',
'MM' => 'tx_myextension_conference_speaker_mm',
// Speakers in the default language, not their translations
'foreign_table_where' => 'AND {#tx_myextension_speaker}.{#sys_language_uid} IN (-1, 0) ORDER BY tx_myextension_speaker.name',
'size' => 5,
'autoSizeMax' => 20,
'fieldControl' => [
'editPopup' => [
'disabled' => false,
'options' => [
'title' => 'my_extension.db:conference.speakers.edit',
],
],
'addRecord' => [
'disabled' => false,
'options' => [
'title' => 'my_extension.db:conference.speakers.add',
// A new speaker comes first in the list of selected speakers
'setValue' => 'prepend',
],
],
'listModule' => [
'disabled' => false,
'options' => [
'title' => 'my_extension.db:conference.speakers.list',
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'speakers',
'',
'before:--div--;my_extension.db:tab.details',
);
Group field
The speaker of a talk with field controls
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
'speaker' => [
'label' => 'my_extension.db:talk.speaker',
'config' => [
'type' => 'group',
'allowed' => 'tx_myextension_speaker',
'maxitems' => 1,
'relationship' => 'manyToOne',
// The speakers are stored in the same folder as the talks
'elementBrowserEntryPoints' => [
'tx_myextension_speaker' => '###CURRENT_PID###',
],
'fieldControl' => [
'editPopup' => [
'disabled' => false,
],
'addRecord' => [
'disabled' => false,
],
'listModule' => [
'disabled' => false,
],
],
'behaviour' => [
'allowLanguageSynchronization' => true,
],
],
],
]);
$GLOBALS['TCA']['tx_myextension_talk']['types']['keynote']['columnsOverrides']['speaker']['config']['minitems'] = 1;
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_talk',
'speaker',
'',
'after:slug',
);
Select field with options
The add control of the speakers of a conference also sets
options. The title option changes the title of the button. With
set set to prepend, a new speaker comes first in the list of
selected speakers:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'speakers' => [
'label' => 'my_extension.db:conference.speakers',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_myextension_speaker',
'MM' => 'tx_myextension_conference_speaker_mm',
// Speakers in the default language, not their translations
'foreign_table_where' => 'AND {#tx_myextension_speaker}.{#sys_language_uid} IN (-1, 0) ORDER BY tx_myextension_speaker.name',
'size' => 5,
'autoSizeMax' => 20,
'fieldControl' => [
'editPopup' => [
'disabled' => false,
'options' => [
'title' => 'my_extension.db:conference.speakers.edit',
],
],
'addRecord' => [
'disabled' => false,
'options' => [
'title' => 'my_extension.db:conference.speakers.add',
// A new speaker comes first in the list of selected speakers
'setValue' => 'prepend',
],
],
'listModule' => [
'disabled' => false,
'options' => [
'title' => 'my_extension.db:conference.speakers.list',
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'speakers',
'',
'before:--div--;my_extension.db:tab.details',
);
Options
disabled
-
- Type
- boolean
- Default
- true
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['addRecord']['disabled']
- Scope
- Display
Disables the field control. Needs to be set to
falseto enable the Create new button
options[pid]
-
- Type
- string
- Default
- ###CURRENT_PID###
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['addRecord']['options']['pid']
- Scope
- Display
- Values
- marker or an integer
pid of the new record. Can be an hard pid setting, or one of these markers, see select foreign_table_where.
Falls back to "current pid" if not set, forces pid=0 if records of this table are only allowed on root level.
###CURRENT_PID### ###THIS_UID### ###SITEROOT###
options[table]
-
- Type
- string
- Default
- First table from property
allowed/foreign_table - TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['addRecord']['options']['table']
- Scope
- Display
- Values
- name of the table
Add a record to this table, falls back to first table from allowed list if not set for
type='group'fields and to foreign_table fortype='select'fields.
options[title]
-
- Type
- string
- Default
LLL:core. core: labels. create New - TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['addRecord']['options']['title']
- Scope
- Display
- Values
- plain text label or label reference
Allows to set a different 'title' attribute to the popup icon.
options[setValue]
-
- Type
- string
- Default
- append
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['addRecord']['options']['setValue']
- Scope
- Display
- Values
- string
Can be one of 'set', 'prepend' or 'append'. With 'set' the given selection is substituted with the new record, 'prepend' adds the new record on top of the list, 'append' adds it at the bottom.