CMS Development

aravet
Participant | Diamond Partner
Participant | Diamond Partner

Default values for repeatable fields do not work

Morning, everyone,

I develop a custom module that is quite complex and flexible in its architecture using local development.
It's a fairly basic module with an image on the left and an explanatory text on the right.
The content on the right is composed of items that are in fact repeatable fields. For each "item" the content creator can select its type: it can be a title, a rich text, an image, a cta...
Each of these types has its own default value.

I would like when dragging & dropping this module in the page to have a default display with a title first, a rich_text second and a cta third.
However the content_format field that is used to choose the type of item does not work (the value is always null).

Here is the default value i would like when i drag & drop:

Capture d’écran 2020-08-17 à 11.49.26.png

Here is my code:

 

 

        "default": [
          {
            "content_format": "title",
            "heading_title": "Default title",
            "heading_level": "h2"
          },
          {
            "content_format": "rich_text",
            "rich_text": "<p>Default Rich Text</p>"
          },
          {
            "content_format": "cta",
            "cta": "defaultctaidhere"
          }
        ],
        "type": "group"
      }

 

 


Here is the result when i drag & drop : 

Capture d’écran 2020-08-17 à 11.56.39.png
Here is the back-end display:

Capture d’écran 2020-08-17 à 11.57.18.png


As you can see, he takes my values well here.
But inside the first one for example :

Capture d’écran 2020-08-17 à 11.58.37.png

The choice field is empty, the other fields must be displayed according to it (using the visibility attribute).

 

Have you ever tried to set a default value to a choice type within a repeatable module? Have you ever encountered this problem?

Thank you very much for your answers,
Have a nice day,
Antoine,

1 Reply 1
sharonlicari
Community Manager
Community Manager

Default values for repeatable fields do not work

Hey @aravet  

 

Thank you for the detailed information provided. This would be helpful for our experts to share their thoughts with you.

 

Hey @Kevin-C @JanetArmstrong @prosa  any advice you can give to @aravet

 

Thank you 😀

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !