Add custom field validation in Content Fragment Model / Content Fragment

Avatar

Avatar

Mayukh007

Avatar

Mayukh007

Mayukh007

01-02-2021

Hello,

 

We have a requirement where we need to add custom field validation when creating a content fragment (CF) using a custom content fragment model (CFM).

Currently when I create a CFM, I only see some limited option like can mark field as required or specify max char limit etc. But what if i need to create a custom date field called "Age" where I can specify Regex or logic that selected date can not be in past date etc, something like that...

 

I know we can create custom data types which I can use in my CFM but I dont see option to add validations on field link Regex, compare values, compare date value with current time etc.

 

We are in AEM 6.5.5.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

BrianKasingli

MVP

Avatar

BrianKasingli

MVP

BrianKasingli
MVP

02-02-2021

@Mayukh007,

It is possible, I have provided a solution around over a week ago, please take a look here -> https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/ootb-validation-options-fo...

}}

In short, you can use JavaScript to append the "pattern" attribute to a given HTML element, from there it will enable HTML validation for the content fragment field itself. Your client library should have a clientlib category of "dam.cfm.authoring.v2", so when you are on the cfm authoring view, your code will be run.

Answers (0)