Page tree
Skip to end of metadata
Go to start of metadata

CompositeFieldDefinition defines a complex field that is composed of multiple simple fields. Use a composite field for objects that cannot be expressed as simple text strings or numbers such as:

  • Setting conditions for selecting the next step in a multistep form.
  • Assigning categories to a content item, where the composite field consists of a category dropdown and a button for reordering categories.
  • Defining an image gallery using a media select field, where the composite media field consist of a thumbnail and caption text. 
  • Specifying an access control list for JCR workspaces, where the composite ACL field consists of permission, scope and path.

class: info.magnolia.ui.form.field.definition.CompositeFieldDefinition

fieldType: composite

Here is a composite field that consists of a text field and a date field.

To export the content of the composite fields for translation via the CTS module, the composite field type has to be registered in the configuration of the module. For details see Registering additional field types.

Composite field properties

Simple composite field definition:

form:
  tabs:
    - name: tabEvent
      label: Event
      fields:
        - name: title
          fieldType: composite
          label: Event
          fields:
            - name: title
              fieldType: text
              label: Title
            - name: date
              fieldType: date
              label: Date
Node nameValue

 form


 tabs


 tabEvent


 fields


 event


 fields


 title


 fieldType

text

 label

Title

 date


 fieldType

date

 label

Date

 fieldType

composite

 label

Event

See Referencing fields for further information.

You can use common field properties and the following properties in a composite field definition:

Properties:

<composite field name>

required

Name of parent composite field.

fields

required

Node containing child fields.

<child field names>

required

Name of the child fields. You can use any simple field definition.

class

required

Field definition class of the child field.

<child field properties>

required/optional

Any properties the child field supports.

layout

optional, default is horizontal

Defines the layout of the child fields: horizontal or vertical.

Properties specific to the composite field.

class

required

Definition class of the composite parent field. Use info.magnolia.ui.form.field.definition.CompositeFieldDefinition.

transformerClass

optional, default is info.magnolia.ui.form.field.transformer.composite.CompositeTransformer

Custom property transformer definition.

Best practice

When nesting composite fields, use the delegating transformer classes, DelegatingCompositeFieldTransformer or DelegatingMultiValueFieldTransformer, rather than the other available transformer classes.