Search code examples
content-management-systemyamlmagnolia

Magnolia Collapsible composite field with multivalue allows me to save but cannot reopen when editing


I have a not too complex form that is a Multivalue of a composite field and within that composite field there is a title and then a collapsible composite field with several fields below.

The tree looks like this:

- tab
  - composite
    - title
    - collapsible composite
      - field 1
      - field 2
      - ...

I'm doing it like this because there are too many fields and ordering them with all the fields open can be a pain, so the idea is to have a composite field with a title and a collapsible composite field so that I can collapse all the fields but have the title still shown.

This works fine, I can add things, reorder, collapse and everything saves correctly.

Collapsed composite field

Opened composite field

However, after saving, when I try to edit my component, I have the following error:

Caused by: java.lang.ClassCastException: info.magnolia.editor.app.field.CollapsibleCompositeFieldDefinition$$EnhancerByCGLIB$$ea3bb8e3 cannot be cast to info.magnolia.ui.form.field.definition.MultiValueFieldDefinition

And here's my code (only the interesting part).

- name: tabTiles
  label: Tiles
  fields:
    - name: tiles
      label: Tiles
      i18n: true
      class: info.magnolia.ui.form.field.definition.MultiValueFieldDefinition
      transformerClass: info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer
      field:
        name: linksCompositeField
        class: info.magnolia.ui.form.field.definition.CompositeFieldDefinition
        transformerClass: info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer
        label: Collapse
        layout: vertical
        fields:
          - name: title
            label: Tile title
            class: info.magnolia.ui.form.field.definition.TextFieldDefinition
          - name: linksCompositeField
            class: info.magnolia.editor.app.field.CollapsibleCompositeFieldDefinition
            transformerClass: info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer
            label: Collapse
            fields:
              - name: icon
                class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
                targetWorkspace: dam
                appName: assets
                required: true
                label: Select image
                identifierToPathConverter:
                  class: info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator
                contentPreviewDefinition:
                  contentPreviewClass: info.magnolia.dam.app.ui.field.DamFilePreviewComponent
              - name: text
                label: Tile text
                class: info.magnolia.ui.form.field.definition.RichTextFieldDefinition
              - name: information
                class: info.magnolia.ui.form.field.definition.StaticFieldDefinition
                label: Link
                value: ''
              - name: linkText
                label: Link text
                class: info.magnolia.ui.form.field.definition.TextFieldDefinition
              - name: link
                label: Link
                class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
                targetWorkspace: website
                appName: pages
              - !include:/foundation-components/dialogs/include/linkTargetSelectField.yaml
              - name: linkTitle
                label: Link title
                class: info.magnolia.ui.form.field.definition.TextFieldDefinition

Any help much appreciated.


Solution

  • Ok, it was frustrating but my composite fields both have the same names... hence the error.