Collection
The
Collection type generates a field for
Inline-Relational-Record-Editing (IRRE), which
allows nesting of other field types. This field type allows
building structures like image sliders, accordions, tabs and so on.
Collections will automatically create custom tables and use the
identifier as table name. It is possible to override this with the
setting
table. Collections are always hidden in the List
module. Usually Collections only have one type. To realise multiple types it is
recommended to extract the definition to a separate
Record Type and use
foreign_table instead.
Custom icon
In order to define a custom icon for your Collection field, you may place an
image file inside assets folder called {identifier}.svg. So for example
if your identifier for the Collection is
my_, then your image
should be named my_collection.svg. Alternatively, you can also provide png
or gif files. These should be 64x64px.
Settings
Tip
All options from Record Types can be used here as well.
| Name | Type | Default | Required |
|---|---|---|---|
| string|array | true | ||
| array | |||
| string | |||
| array | true | ||
| integer | "0" | ||
| integer | "0" | ||
| string | oneToMany | ||
| bool|null | null | ||
| string | top | ||
| boolean | |||
| boolean | true | ||
| boolean | |||
| string | |||
| string | |||
| boolean | false | ||
| boolean | false | ||
| boolean | true | ||
| boolean | |||
| boolean | |||
| boolean | |||
| object | |||
| boolean | |||
| boolean | |||
| string (table) | |||
| string (field) | |||
| boolean | false | ||
| boolean | false | ||
| array | [] | ||
| integer | |||
| boolean | false | ||
| boolean | false | ||
| boolean | true | ||
| array | |||
| object | |||
| object | |||
| object | |||
| array | |||
| string | |||
| string | |||
| object | |||
| string | |||
| string | |||
| string | |||
| string | |||
| string | |||
| string | |||
| object | |||
| boolean | false | ||
| integer | 1 | ||
| string | |||
| string | |||
| string | |||
| array | [] |
labelField
-
- Type
- string|array
- Required
true
Defines which field should be used as the title of the record. If not defined, the first valid child field will be used as the label. It is possible to define an array of fields, which will be displayed comma-separated in the backend.
# a single field for the label labelField: title # multiple fields will be displayed comma-separated labelField: - title - textCopied!
fallbackLabelFields
-
- Type
- array
Defines which fields should be used as fallback, if
labelis not filled. The first filled field which is found will be used. Can only be used if there is only oneField labelfield defined.Field # fallback fields will be used, if title from labelField is empty labelField: title fallbackLabelFields: - text1 - text2Copied!
table
-
- Type
- string
Alternative table name for the Collection. Default is
identifierwith prefix if enabled.table: tx_vendor_my_custom_table_nameCopied!
fields
-
- Type
- array
- Required
true
Configures a set of fields as repeatable child objects. All fields defined in field types are possible as children. It is also possible to further nest Collection fields.
Example:
fields: - identifier: text type: Text - identifier: image type: FileCopied!
minitems
-
- Type
- integer
- Default
- "0"
Minimum number of child items. Defaults to 0. JavaScript record validation prevents the record from being saved if the limit is not satisfied.
maxitems
-
- Type
- integer
- Default
- "0"
Maximum number of child items. Defaults to a high value. JavaScript record validation prevents the record from being saved if the limit is not satisfied.
relationship
-
- Type
- string
- Default
- oneToMany
The relationship defines the cardinality between the relations. Possible values are
one(default),To Many manyandTo One one. In case of a [x]toOne relation, the processed field will be filled directly with the record instead of a collection of records. In addition,To One maxitemswill be automatically set to1.
appearance.collapseAll
-
- Type
- bool|null
- Default
- null
- Default (null): Last collapsed/expanded state is remembered
- true: Show all child records collapsed
- false: Show all child records expanded
appearance.levelLinksPosition
-
- Type
- string
- Default
- top
Defines where to show the "New record" link in relation to the child records. Valid keywords are
top,bottomandboth.
appearance.expandSingle
-
- Type
- boolean
When enabled, only one child record is expanded at a time. Clicking a collapsed record collapses the currently open one.
appearance.showNewRecordLink
-
- Type
- boolean
- Default
- true
Show or hide the "New record" link.
appearance.newRecordLinkAddTitle
-
- Type
- boolean
Adds the title of the foreign table to the "New record" link label.
appearance.newRecordLinkTitle
-
- Type
- string
Overrides the "New record" link label with a localized string. Only takes effect if
appearance.is not set to true.new Record Link Add Title
appearance.createNewRelationLinkTitle
-
- Type
- string
Overrides the "Create new relation" button label with a localized string. Only useful when the element browser is enabled.
appearance.useCombination
-
- Type
- boolean
- Default
- false
Enables editing of intermediate table attributes alongside the related child record in bidirectional relations. Requires
foreign_andselector foreign_to be set to the same field.unique
appearance.suppressCombinationWarning
-
- Type
- boolean
- Default
- false
Suppresses the warning message shown when
appearance.is active.use Combination
appearance.useSortable
-
- Type
- boolean
- Default
- true
Activates drag & drop sorting of child records.
appearance.showPossibleLocalizationRecords
-
- Type
- boolean
Show unlocalized records that exist in the original language but have not yet been translated.
appearance.showAllLocalizationLink
-
- Type
- boolean
Show a "Localize all records" link to fetch untranslated records from the original language.
appearance.showSynchronizationLink
-
- Type
- boolean
Show a "Synchronize" link to update to a 1:1 translation with the original language.
appearance.enabledControls
-
- Type
- object
Enables or disables individual controls on child records. Available keys with their defaults:
- info (bool, default true)
- Show or hide the info control.
- new (bool, default true)
- Show or hide the "new" control.
- dragdrop (bool, default true)
- Show or hide the drag & drop handle.
- sort (bool, default false)
- Show or hide the sort arrows.
- hide (bool, default true)
- Show or hide the hide/show toggle.
- delete (bool, default true)
- Show or hide the delete control.
- localize (bool, default true)
- Show or hide the localize control.
Example:
appearance: enabledControls: sort: true delete: falseCopied!
appearance.showPossibleRecordsSelector
-
- Type
- boolean
Hides the foreign record selector from the interface even when
foreign_is configured. Useful when replacing the selector with a custom control viaselector custom.Controls
appearance.elementBrowserEnabled
-
- Type
- boolean
Shows or hides the element browser button in inline records.
foreign_table
-
- Type
- string (table)
It is possible to reference another table instead of creating a new one. This table can be defined by another Content Block, but can also be an existing table defined by the Core or another extension.
Note
When you use
foreign_it is not possible to definetable fieldsanymore. They will not be evaluated.
foreign_field
-
- Type
- string (field)
It is possible to override the field name pointing to the parent record. Per default it is called
foreign_. This corresponds with the TCA option foreign_field.table_ parent_ uid
allowedRecordTypes
-
- Type
- array
- Default
- []
This option allows you to restrict possible record types for the type selector of the child record. The order of definition is used to sort the items. The first item in the list will always be the default type.
allowedRecordTypes: - text - imagesCopied!
autoSizeMax
-
- Type
- integer
The inline field will never grow larger than this number of items before a scrollbar appears.
behaviour.allowLanguageSynchronization
-
- Type
- boolean
- Default
- false
Allows to select if localization uses custom or default language value.
behaviour.disableMovingChildrenWithParent
-
- Type
- boolean
- Default
- false
Disables automatic moving of child records when the parent record is moved.
behaviour.enableCascadingDelete
-
- Type
- boolean
- Default
- true
When disabled, child records are not deleted when the parent record is deleted.
customControls
-
- Type
- array
A list of custom controls (user functions) used to extend the inline field interface. Each entry requires a
userkey.Func
fieldControl
-
- Type
- object
See TCA fieldControl.
fieldInformation
-
- Type
- object
See TCA fieldInformation.
fieldWizard
-
- Type
- object
See TCA fieldWizard.
filter
-
- Type
- array
Defines filters for item values. Each entry requires a
userkey and an optionalFunc parametersobject. Does not work in combination with a wizard.
foreign_default_sortby
-
- Type
- string
ORDER BY clause for sorting child records when
foreign_is not defined.sortby
foreign_label
-
- Type
- string
Field name of the child record to use as the inline element title.
foreign_match_fields
-
- Type
- object
Field-value pairs inserted into and matched against when writing/reading IRRE relations. Allows reusing the same child table across multiple parent fields.
foreign_selector
-
- Type
- string
Field name of the child record used as a selector to show all possible related records.
foreign_sortby
-
- Type
- string
Field on the child record that stores the manual sort order.
foreign_table_field
-
- Type
- string
Field on the child record pointing to the parent table name. Used together with
share.Across Tables
foreign_unique
-
- Type
- string
Field on the child record that must be unique across all children of a parent record.
MM
-
- Type
- string
Table name for storing the MM relation. Used together with
foreign_.table
MM_opposite_field
-
- Type
- string
Enables bidirectional MM relations. Set to the field name on the local side when configuring the foreign side.
overrideChildTca
-
- Type
- object
Overrides TCA configuration of child records (e.g.
sys_) attached to this field.file_ reference
readOnly
-
- Type
- boolean
- Default
- false
Renders the field in a way that the user can see the value but cannot edit it.
size
-
- Type
- integer
- Default
- 1
Number of visible rows in the inline field.
symmetric_field
-
- Type
- string
Works like
foreign_for bidirectional symmetric relations. Defines the field storing the uid of the "other" parent.field
symmetric_label
-
- Type
- string
Overrides the label defined in
labelwhen viewing a symmetric relation from the other side.Field
symmetric_sortby
-
- Type
- string
Works like
foreign_for bidirectional symmetric relations.sortby
overrideType
-
- Type
- array
- Default
- []
Type Overrides can be used to override the Record Definition in the context of as single field. This option only makes sense, if you don't define
fields, but an externalforeign_, that you want to override. Refer to the API documentation if you want to learn more.table name: friendsoftypo3/example table: tx_friendsoftypo3_example prefixFields: false labelField: title fields: - identifier: title type: Text label: Title - identifier: collection_override type: Collection foreign_table: tx_hov_domain_model_record1 overrideType: record1: - identifier: type type: Select useExistingField: true - identifier: title type: Text useExistingField: true - identifier: custom_field type: TextCopied!
Example
Minimal
name: example/collection
fields:
- identifier: collection
type: Collection
labelField: text
fields:
- identifier: text
type: Text
Advanced / use case
name: example/collection
fields:
- identifier: slides
type: Collection
labelField: title
maxitems: 5
minitems: 1
appearance:
collapseAll: true
levelLinksPosition: both
fields:
- identifier: image
type: File
minitems: 1
maxitems: 1
- identifier: title
type: Text
This custom table
my_ needs to be defined as a
Record Type in order to be used as a foreign
table in
slides.
name: example/slide
table: my_slide
labelField: title
fields:
- identifier: title
type: Text
- identifier: image
type: File
name: example/collection
fields:
- identifier: slides
type: Collection
foreign_table: my_slide
shareAcrossTables: true
shareAcrossFields: true