Skip to main content
Mar 7, 2023 10:32 AM UTC
Solved

Required Fields and Dropdown Help in AEM as Cloud

Hi,

I am using dropdown field with show/hide property which has four values and it will populate different set of required field items based upon the selection.So, when i author and try to save any one of the dropdown items , it throws error showing the required fields in other dropdown items are not authored.

Could you please suggest whether we can use required fields with show/hide property and let me know your thoughts on this.

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Rohit_Utreja
Rohit_UtrejaAccepted solution
Community Advisor
Mar 7, 2023 4:18 PM UTC

@prasanthnapa2904 

It can be achieved by following code
1. add granite:data for all those fields.
2. add extraclientlibs prop at dialog level.

3. create a new clientlib with following code
$(document).on("change", .......capture-the-dropdown...function (e) {

capture all fields by using css class mentioned in granite:data earlier.

capturedField.adaptTo("foundation-field").setRequired(false);

}

 

I hope it helps.

BR, Rohit

5 replies

TarunKumar
Community Advisor
Community Advisor
Mar 7, 2023 2:14 PM UTC

Hi @prasanthnapa2904 

You can use required field in show/hide for the dropdown but you will have to make sure that required field is removed when you switch back to different selection.
This validation can be applied through jQuery/JavaScript so on show hide of the dropdown selection you will have to add and remove required field.

Translate
Kiran_Vedantam
Community Advisor
Community Advisor
Mar 7, 2023 3:24 PM UTC

Hi @prasanthnapa2904 

 

Create a custom JS and add the below logic

 

$("name='./<your field name>'").attr("aria-required", "true");

 

Hope it helps!

Thanks,
Kiran Vedantam.

Translate
Rohit_Utreja
Community Advisor
Rohit_UtrejaCommunity AdvisorAccepted solution
Community Advisor
Mar 7, 2023 4:18 PM UTC

@prasanthnapa2904 

It can be achieved by following code
1. add granite:data for all those fields.
2. add extraclientlibs prop at dialog level.

3. create a new clientlib with following code
$(document).on("change", .......capture-the-dropdown...function (e) {

capture all fields by using css class mentioned in granite:data earlier.

capturedField.adaptTo("foundation-field").setRequired(false);

}

 

I hope it helps.

Translate
BR, Rohit
Sep 21, 2023 3:17 AM UTC

@prasanthnapa2904 
Is it working for you? I'm also facing the same problem.

Translate
New Member
Nov 6, 2023 8:39 AM UTC

Can someone please provide the end to end solution for it.I am also facing the same issue

Translate