How to do a multiple include in Magnolia CMS?

65 views Asked by At

On my sampleDialog.yaml, I want to include multiple files that contains different types of fields.

SampleDialog.yaml

This one is working as expected it loads all the fields on that file.

label: Sample
form:
  properties:!include:/sample-files/file1.yaml

But if I try to include multiple files, it is not working.

I already tried different formats like:

label: Sample
form:
  properties:
    - !include:/sample-files/file1.yaml
    - !include:/sample-files/file2.yaml

label: Sample
form:
  properties:
    !include:/sample-files/file1.yaml
    !include:/sample-files/file2.yaml

label: Sample
form:
  properties:
    !include: "/sample-files/file1.yaml"
    !include: "/sample-files/file2.yaml"

Anyone have an idea?

1

There are 1 answers

0
Miroslav Pashaliski On

Please see example below on how you can do that, please note that the files that are used as "includes" in the example are created with idea to be reused so the field/prop is defined within the dialog.

  • Under properties define fields that you want to use into the dialog.

  • Include the defined fileds into some specific tab from dialog definition.

Dialog definition example:

!inherit:global-elements:components/link

form:
  properties:
    iconType:
      !include:/webmasters-light-module/dialogs/includes/iconSwitchableField.yaml
    bodyStyle:
      !include:/webmasters-light-module/dialogs/components/heroSection/style/bodyStyle.yaml  
  layout:
    $type: tabbedLayout
    tabs:
      - name: tabMain
        fields:
          - name: iconType
          - name: bodyStyle 

Field definition example (used as include file):

$type: staticField
label: ''
value: Body Style Configuration