Thursday 7 February 2019

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


For 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, 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 dataype has properties as below,
  • fieldIcon
  • fiedPropResourceType
  • fieldProperties
  • fieldResourceType
  • fieldTitle
  • fieldViewResourceType
  • renderType
  • valueType

There are some additional fields which 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 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.

No comments:

Post a Comment