Expand my Community achievements bar.

SOLVED

All Show-hide dropdown fields are getting stored at JCR

Avatar

Level 1

I've implemented a regular showhide dropdown feature in aem dialog. Show-hide feature is working fine. First I selected first option and authored the fields under that option. Later I selected the second option and authored the fields under second option. But at content page node level both values are getting stored. My requirement is, if I switch the dropdown options from first select option to second select option, whatever the fields authored under first option should not store at content page node level. I'm not looking for any custom implementation. Do we've any OOTB AEM feature to achieve this requirement?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @vvenkateshr 

 

With show-hide, the fields still exist in the DOM. They are not cleared. This provides that benefit, that if you have toggled by-mistake, the pre-filled values are not lost.

 

In your code, you would have to check the value of the dropdown, and the decide whether you want to consume/ignore the other fields.

 

Else, you would need to customize to clear the fields, in which case you loose the benefit stated above. For customization, please refer to threads

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/clear-values-in-fields-on-... 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-i-clear-data-from-... 


Aanchal Sikka

View solution in original post

3 Replies

Avatar

Community Advisor

Hello @vvenkateshr - 

 

In AEM, there is no out-of-the-box feature specifically designed to handle the scenario you described, where the authored fields under one dropdown option should not be stored at the content page node level when switching to another dropdown option. By default, AEM saves all the values entered in the dialog fields to the content page node when the dialog is saved.

 

However, this can be handled via custom implementations.

Avatar

Correct answer by
Community Advisor

Hello @vvenkateshr 

 

With show-hide, the fields still exist in the DOM. They are not cleared. This provides that benefit, that if you have toggled by-mistake, the pre-filled values are not lost.

 

In your code, you would have to check the value of the dropdown, and the decide whether you want to consume/ignore the other fields.

 

Else, you would need to customize to clear the fields, in which case you loose the benefit stated above. For customization, please refer to threads

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/clear-values-in-fields-on-... 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-i-clear-data-from-... 


Aanchal Sikka

Avatar

Community Advisor

Hey @vvenkateshr you can achieve it using this - https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/clear-values-in-fields-on-...

or Create a sling model and perform the following operations in author mode only - examine the selected value of a dropdown and remove other values using Node APIs accordingly.

-Thanks

Bilal