Collection

type => 'inline' // TCA alternativeSql: false

The Collection type generates a field for Inline-Relational-Record-Editing (IRRE), which allows nesting of other field types as children. This field type allows building structures like image sliders, accordion, tabs and so on.

First-level options

All options, which can be defined for Record Types can be used here as well. Note that labelField is required.

fields
Required

true

Type

array

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: File

Settings

minitems
Required

false

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
Required

false

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.

foreign_table
Required

false

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. In case of another Content Block, the option aggregateRoot has to be set to false, so that required fields are created. Existing tables need to manually define the foreign_table_parent_uid, tablenames and fieldname fields.

For more advanced configuration refer to the TCA documentation

Custom icon

In order to define a custom icon for your Collection field, you may place an image file inside Assets called {identifier}.svg. So for example if your identifier for the Collection is my_collection, then your image should be named my_collection.svg. Alternatively, you can also provide png or gif files. These should be 64x64px.

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
    fields:
      - identifier: image
        type: File
        minitems: 1
        maxitems: 1
      - identifier: title
        type: Text

This custom table my_slide 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
aggregateRoot: false
labelField: title
fields:
  - identifier: title
    type: Text
  - identifier: image
    type: File

name: example/collection
fields:
  - identifier: slides
    type: Collection
    foreign_table: my_slide