items

items
Type:array
Scope:Display / Proc.
RenderType:all

Contains the elements for the selector box unless the property “foreign_table” or “special” has been set in which case automated values are set in addition to any values listed in this array.

Each element in this array is in itself an array where:

#1 First value is the item label (string or LLL reference)

#2 Second value is the value of the item

  • The special value --div-- was used to insert a non-selectable value that appears as a divider label in the selector box. It is kept for backwards-compatible reasons. Use item groups for custom selects instead.
  • Values must not contain “,” (comma) and “|” (vertical bar). If you want to use “authMode” you should also refrain from using “:” (colon).
#3 Third value is an optional icon. For custom icons use a path prepended with “EXT:” to refer to an image
file found inside an extension or use an registered icon identifier.

#4 Fourth value is the key of the item group.

#5 Fifth value is reserved as keyword “EXPL_ALLOW” or “EXPL_DENY”. See
property authMode / individual for more details.

Note

When having a zero as second value and the field is of type int(10) in the database, make sure to define the default value as well in TCA: 'default' => 0. Otherwise issues may arise e.g. with MySQL strict mode.

Examples

Simple items definition with label and value

      'select_single_1' => [ 
         'exclude' => 1,
         'label' => 'select_single_1 two items, long text description',
         'description' => 'field description',
         'config' => [ 
            'type' => 'select',
            'renderType' => 'selectSingle',
            'items' => [ 
               '0' => [ 
                  '0' => 'foo and this here is very long text that maybe does not really fit into the form in one line. Ok let us add even more text to see how this looks like if wrapped. Is this enough now? No? Then let us add some even more useless text here!',
                  '1' => 1,
               ],
               '1' => [ 
                  '0' => 'bar',
                  '1' => 'bar',
               ],
            ],
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_select"

Items definition with label, value and icon

A more complex example could be this (includes icons):

      'select_single_4' => [ 
         'exclude' => 1,
         'label' => 'select_single_4 items with icons',
         'config' => [ 
            'type' => 'select',
            'renderType' => 'selectSingle',
            'items' => [ 
               '0' => [ 
                  '0' => 'foo 1',
                  '1' => 'foo1',
                  '2' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
               ],
               '1' => [ 
                  '0' => 'foo 2',
                  '1' => 'foo2',
                  '2' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
               ],
            ],
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_select"

A typical sys_language_uid field

The icons can also be referenced by their identifier in the Icon API

      'sys_language_uid' => [ 
         'exclude' => true,
         'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
         'config' => [ 
            'type' => 'language',
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_basic"

Select checkbox field with icons and descriptions

Descriptions are only displayed in render type selectCheckbox.

Screenshot of field tx_styleguide_elements_select:select_checkbox_3

Screenshot of field tx_styleguide_elements_select:select_checkbox_3

      'select_checkbox_3' => [ 
         'exclude' => 1,
         'label' => 'select_checkbox_3 icons, description',
         'config' => [ 
            'type' => 'select',
            'renderType' => 'selectCheckBox',
            'items' => [ 
               '0' => [ 
                  '0' => 'foo 1',
                  '1' => 1,
                  '2' => '',
                  '3' => null,
                  '4' => [ 
                     'title' => 'optional title',
                     'description' => 'optional description',
                  ],
               ],
               '1' => [ 
                  '0' => 'foo 2',
                  '1' => 2,
                  '2' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
                  '3' => null,
                  '4' => 'LLL:EXT:styleguide/Resources/Private/Language/locallang.xlf:translatedHelpTextForSelectCheckBox3',
               ],
               '2' => [ 
                  '0' => 'foo 3',
                  '1' => 3,
                  '2' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
               ],
               '3' => [ 
                  '0' => 'foo 4',
                  '1' => 4,
               ],
            ],
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_select"

SelectSingle field with itemGroups

A select single field of size 6 with 3 item groups and one item without group.

      'select_single_17' => [ 
         'exclude' => 1,
         'label' => 'select_single_16',
         'description' => 'itemGroups, size=6',
         'config' => [ 
            'type' => 'select',
            'renderType' => 'selectSingle',
            'items' => [ 
               '0' => [ 
                  '0' => 'item 1',
                  '1' => 1,
                  '2' => '',
                  '3' => 'group1',
               ],
               '1' => [ 
                  '0' => 'item 2',
                  '1' => 2,
                  '2' => '',
                  '3' => 'group1',
               ],
               '2' => [ 
                  '0' => 'item 3',
                  '1' => 3,
                  '2' => '',
                  '3' => 'group3',
               ],
               '3' => [ 
                  '0' => 'item 4',
                  '1' => 3,
               ],
            ],
            'itemGroups' => [ 
               'group1' => 'Group 1 with items',
               'group2' => 'Group 2 with no items',
               'group3' => 'Group 3 with items',
            ],
            'size' => 6,
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_elements_select"