Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to edit a template to make a field required

Avatar

Level 2

Two questions:

  1. How do you edit a template (Tools > Template) that displays this message when trying to edit:

    "TEMPLATE EDITOR: This template is not a draft anymore and might already be referenced by one or more pages. Editing the structure will affect all the pages referencing it."?

  2. How do you make one of the fields in this existing template a required field?

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

"TEMPLATE EDITOR: This template is not a draft anymore and might already be referenced by one or more pages. Editing the structure will affect all the pages referencing it."

- This is a generic warning message, to inform a template editor that his actions will affect all pages.

 

Required field

To enforce a mandatory field for all pages generated from this template, it's essential to specify the required attribute for the field within the page component utilized by this template.

Go to the template in CRXDE. look for sling:resourceType attribute on structure node.

 

aanchalsikka_0-1693900873934.png

 

- Go to this page component. Drill down to the field that you want to make mandatory. Add the required attribute, based on the documentation for that field. Example: for a textfield (granite/ui/components/coral/foundation/form/textfield), documentation is https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/...

aanchalsikka_2-1693901155680.png

 

OOTB example of mandatory field is Title field for pages

 

 


Aanchal Sikka

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @kayest 

 

1. To edit a template, use tools>General>Template. It's showing you this warning because this template is already enabled and pages are built using this template. If you change anything on this template, it will affect all other pages built using this template.

 

2. Can you elaborate more on which field you want to make as required? To make a field required you have to add a property required="true". In case you need to make any template properties required, you need to overlay the template properties and set that property required="true"

 

Hope this helps.

Avatar

Level 2

Hi @Avinash_Gupta_ - The field we need to make mandatory is a custom field, but the only choices I have on Tools>General>Template>ThisTemplate are Policy, Lock and Layout. How do I get to where I can add the property you mentioned? Thanks. 

Avatar

Correct answer by
Community Advisor

"TEMPLATE EDITOR: This template is not a draft anymore and might already be referenced by one or more pages. Editing the structure will affect all the pages referencing it."

- This is a generic warning message, to inform a template editor that his actions will affect all pages.

 

Required field

To enforce a mandatory field for all pages generated from this template, it's essential to specify the required attribute for the field within the page component utilized by this template.

Go to the template in CRXDE. look for sling:resourceType attribute on structure node.

 

aanchalsikka_0-1693900873934.png

 

- Go to this page component. Drill down to the field that you want to make mandatory. Add the required attribute, based on the documentation for that field. Example: for a textfield (granite/ui/components/coral/foundation/form/textfield), documentation is https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/...

aanchalsikka_2-1693901155680.png

 

OOTB example of mandatory field is Title field for pages

 

 


Aanchal Sikka