[‘palettes’]

Introduction

If editing records in the backend, all fields are usually displayed after each other in single rows. Palettes provide a way to display multiple fields next to each other if the browser window size allows this. They can be used to group multiple related fields in one combined section.

Each palette has a name and can be referenced by name from within the [‘types’] section.

Examples

TCA of table pages specifies a series of palettes, let’s have a closer look at one of them:

'palettes' => [
    'caching' => [
        'showitem' => '
            cache_timeout;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.cache_timeout_formlabel,
            cache_tags,
            no_cache;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.no_cache_formlabel
        ',
    ],
    ...
],

This specifies the palette caching. It is then referenced in the types section for “normal” tables on tab “Behaviour”:

'types' => [
    '1' => [
        'showitem' => '
            ...
            --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,
                ...
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching,
                ...
            ...
        ',
    ],
    ...
],
Caching palette in pages

Caching palette in pages

It is also possibly to define the label of a palette directly in the palette definition. Declaring the label in an ‘palettes’ array can reduce boilerplate declarations if a palette is used over and over again in multiple types. If a label is defined for a palette this way, it is always displayed. Setting a specific label in the ‘types’ array for a palette overrides the default label that was defined within the ‘palettes’ array. There is no way to unset a label that is set within the ‘palettes’ array. It will always be displayed.

Example:

'types' => [
   'myType' => [
      'showitem' => 'aField, --palette--;;aPalette, someOtherField',
   ],
],
'palettes' => [
   'aPalette' => [
      'label' => 'LLL:EXT:myExt/Resources/Private/Language/locallang.xlf:aPaletteDescription',
      'showitem' => 'aFieldInAPalette, anotherFieldInPalette',
   ],
],

isHiddenPalette

Datatype
boolean
Description

If set to true, this palette will never be shown, but the fields of the palette are technically rendered as hidden elements in FormEngine.

This is sometimes useful when you want to set a field’s value by JavaScript from another user-defined field. You can also use it along with the IRRE (TCA columns type inline) foreign_selector feature if you don’t want the relation field to be displayed (it must be technically present and rendered though, that’s why you should put it to a hidden palette in that case).

Note

The “isHiddenPalette” concept is more a hack than a solution in current FormEngine code. It has been introduced for the “FAL” file resource handling to have virtual fields which can be handled in JavaScript but are not displayed to the editor. It comes with the price of a bunch of HTML that is disabled via CSS if editing those records in the backend. The core will sooner or later reconsider this solution and substitute it with something more appropriate. Extension authors should stay away from this property if possible to not run into upgrade troubles if that happens.

label

Datatype
string

Description

Allows to display a localized label text as a dedicated entry into the palette declaration, instead as a part of the types configuration. By using the explicit label entry, code duplication upon reusing existing palettes can be reduced. The label is always shown with the palette, no matter where it is referenced.

Before:
'types' => [
    'myType' => [
        'showitem' => 'aField, --palette--;LLL:EXT:myExt/Resources/Private/Language/locallang.xlf:aPaletteDescription;aPalette, someOtherField',
    ],
],
'palettes' => [
    'aPalette' => [
        'showitem' => 'aFieldInAPalette, anotherFieldInPalette',
    ],
],
After:
'types' => [
    'myType' => [
        'showitem' => 'aField, --palette--;;aPalette, someOtherField',
    ],
],
'palettes' => [
    'aPalette' => [
        'label' => 'LLL:EXT:myExt/Resources/Private/Language/locallang.xlf:aPaletteDescription',
        'showitem' => 'aFieldInAPalette, anotherFieldInPalette',
    ],
],

showitem

Datatype
string (list of field names)
Description

Required.

Specifies which fields are displayed in which order in the palette, examples:

'showitem' => 'aFieldName, anotherFieldName',
'showitem' => 'aFieldName;labelOverride, anotherFieldName',
'showitem' => 'aFieldName, anotherFieldName, --linebreak--, yetAnotherFieldName',

This string is a comma separated list of field names from [‘columns’] section, each field can optionally have a second, semicolon separated field to override the default label property of the field.

Instead of a field name, the special keyword --linebreak-- can be used to place groups of fields on single lines. Note this line grouping only works well if the browser window size allows multiple fields next to each other, if the width is not sufficient the fields will wrap below each other anyways.

Important

A field name must only appear once in the entire record. Do not reference a single field within the showitem list of a types section and again in a palette used in the same type. Don’t use a field in multiple palettes referenced in a type, or multiple times in one palette.