SelectText
The
Select type generates a simple select field, which only allows
simple text.
Settings
default
-
- Type
- string
Default value set if a new record is created.
items
-
- Type
- array
Contains the elements for the selector box. Each item is an array. An item consists of a
labeland avalue.Example:
items: - label: 'The first' value: 'first' - label: 'The second' value: 'second' - label: 'The third' value: 'third'Copied!Tip
You can omit the label, if you have the translation already in your labels.xlf file.
items: - value: 'first' - value: 'second' - value: 'third'Copied!Tip
You can also use icons so they are displayed in the backend. See Advanced / use case for a full example.
items: - value: 'first' icon: content-beside-text-img-left - value: 'second' icon: content-beside-text-img-right - value: 'third' icon: content-beside-text-img-above-centerCopied!For this you need the following setting according to the TCA documentation.
fieldWizard: selectIcons: disabled: falseCopied!XLF translation keys for items have the following convention:
<body> <trans-unit id="FIELD_IDENTIFIER.items.first.label"> <source>Label for item with value one</source> </trans-unit> <trans-unit id="FIELD_IDENTIFIER.items.second.label"> <source>Label for item with value two</source> </trans-unit> <trans-unit id="FIELD_IDENTIFIER.items.VALUE.label"> <source>Label for item with value VALUE</source> </trans-unit> </body>Copied!
Example
Minimal
name: example/select-text
fields:
- identifier: select_text
type: SelectText
items:
- label: 'The first'
value: 'first'
- label: 'The second'
value: 'second'
Copied!
Advanced / use case
Select with icons:
name: example/select-text
fields:
- identifier: select_text_icons
type: SelectText
fieldWizard:
selectIcons:
disabled: false
default: 'text-left'
items:
- label: 'Image beside text (left)'
value: 'text-left'
icon: content-beside-text-img-left
- label: 'Image beside text (right)'
value: 'text-right'
icon: content-beside-text-img-right
- label: 'Image above text (center)'
value: 'text-center'
icon: content-beside-text-img-above-cent
Copied!