How to insert a complex type in submodel on Magnolia CMS

31 Views Asked by At

I am a beginner in Magnolia CMS and I want to add a switchable like the picture below.

This switchable in function of the type selected (interne or externe) on the radiobutton will display different things below : link to an already existing link in the application if "interne" is selected or just a text field if "externe" is selected.

The following code works for a component and I want exactly the same in the submodel below :

    switchable:
      label: Lier le bouton
      $type: switchableField
      removePreviouslySelected: true
      field:
        name: switchable
        $type: radioButtonGroupField
        datasource:
          $type: optionListDatasource
          options:
            - name: interne
              value: interne
              label: interne
            - name: externe
              value: externe
              label: externe
      itemProvider:
        $type: currentItemProvider
      forms:
        - name: interne
          properties:
            interne:
              $type: pageLinkField
              label: Redirection interne
              targetWorkspace: website
              appName: pages
              required: true
              showOptions: true
              textInputAllowed: true
              converterClass: info.magnolia.ui.editor.converter.JcrNodeToPathConverter
        - name: externe
          properties:
            externe:
              $type: textField
              label: Redirection externe
              required: true
              validators:
                externe:
                  $type: regexpValidator
                  pattern: ^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]
                  errorMessage: Entrez une URL valide SVP

It seems not possible to do it on a submodel like this :

  subModels:
    - name: elementParentHaut
      properties:
        - name: icone
          label: Icône
          type: asset
        - name: alt
          label: Texte alternatif
        - name: switchable
          label: Lien
          type: <i want my switchable here>

Do you have any idea about how to do it ?

Thank you.

I already tried refering to the submodel from the app file but you cannot refere to a submodel from the app file. You can only refere to the model ...

0

There are 0 best solutions below