Content Fragment Model - Key & Value Pair | Community
Skip to main content
Level 2
July 31, 2024
Solved

Content Fragment Model - Key & Value Pair

  • July 31, 2024
  • 3 replies
  • 1613 views

Hello community,

 

I am trying to implement a key-value pair field to content fragment model. 

For example, as shown in the screenshot below, users should be able to add as many key-value pairs as they want, but instead of being one field below Fragment Reference section, there should be two fields: one for Key and another for Value. I didn't see anything like such in the already available options. Could you help me with a way to implement this or point me to existing way to add this?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by narendiran_ravi

You can follow this blog - https://jimfrenette.com/aem/content-fragments/composite-multifield/- to create a composite multifield like an AEM dialog multifield and add it directly inside the content fragment model via CRX. 

3 replies

pulkitvashisth
Community Advisor
Community Advisor
July 31, 2024

Hi @keno6396 
A similar discussion is on this as well
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/multifield-or-multfield-like-structure-for-content-fragment/m-p/688118#M171533
You can checkout my comment on above post.
As well as the accepted solution if that helps.

narendiran_ravi
narendiran_raviAccepted solution
Level 6
August 1, 2024

You can follow this blog - https://jimfrenette.com/aem/content-fragments/composite-multifield/- to create a composite multifield like an AEM dialog multifield and add it directly inside the content fragment model via CRX. 

keno6396Author
Level 2
August 5, 2024

Thank you. I followed the instructions on that link to achieve what I wanted: composite multifield. Is there way to make that as data type in CFM instead of customizing existing model?

narendiran_ravi
Level 6
August 5, 2024

I have created a separate cfm to have these key value pairs as data types and use that as a multivalued fragment reference in the main model. Basically you will have a seperate model for key value pairs and refer that in main cfm via fragment reference. In this way you will have a proper schema incase you are exposing this via GraphQL

kautuk_sahni
Community Manager
Community Manager
August 1, 2024

@keno6396 Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni