March 22, 2020
Estimated Post Reading Time ~

How can we create a custom datatype in the content fragment models in AEM

For the majority of the use cases, the given content fragment datatypes will satisfy any use cases. But still, if we need to extend the data type functionality further, the below approach can be tried.

To start with, let us understand the data type structure in AEM.

Content Fragment model data types are configured at:
/libs/settings/dam/cfm/models/formbuilderconfig/datatypes/items/enumeration

and each datatype has properties as below,

fieldIcon
fiedPropResourceType
fieldProperties
fieldResourceType
fieldTitle
fieldViewResourceType
renderType
valueType

There are some additional fields that are specific to the fields.

Now, if you observe closely,

fiedPropResourceType having string value 'dam/cfm/models/editor/components/datatypes/field'
fieldIcon, fiedTitle -are data type naming specific.
fieldResourceType, renderType, valueType - are behavior specific to the data types.

All the fieldResourceType values are referred from /libs/granite/ui/components/coral/foundation, /libs/dam/cfm/models/editor/components,
/libs/dam/cfm/admin/components etc.

Below given a screenshot of default Boolean data type properties.


Custom?
Now say if you need to create a custom data type for the content fragment, you can create a project-specific structure of the data type referring to the default one, the same way we extend the components.

If there is any other way to implement this, please let me know through the comments.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.