Magnolia 5.3 reached end of life on June 30, 2017. This branch is no longer supported, see End-of-life policy.

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

Here is a composite event field. It consists of a text field and a date field.

The field is configured like this:

Node nameValue

 event

 

 fields

 

 title

 

 class

info.magnolia.ui.form.field.definition.TextFieldDefinition

 label

Title

 date

 

 class

info.magnolia.ui.form.field.definition.DateFieldDefinition

 label

Date

 class

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

 label

Event

You can use all common field properties and the following:

PropertyDescriptionDefault

<composite field>

Parent composite field.

 

fields

Node that contains the child fields.

 

<child field 1>

Child field. You can use any simple field definition.

 

class

Definition class of the child field.

 

<child field 2>

 

 

class

 

 

class

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

 

layout

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

transformerClass

Custom property transformer definition. Optional. The default for composite is info.magnolia.ui.form.field.transformer.composite.CompositeTransformer.

 

Best practice

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