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 hide/show fields based on checkbox in AEM 6.5?

Avatar

Level 3

Can someone please give me a step by step solution to hide show a set of fields based on checkbox in AEM 6.5? I have tried everything I could find on Google and nothing works as expected. It's ridiculous how we're up to AEM 6.5 and Adobe still hasn't provided an out of the box solution for this. And if there is an out of the box solution it's ridiculous how tough it is to find documentation for it.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hello, 

Your question inspired me to write a tutorial on how to show/hide or enable/disable fields based on a checkbox (or any other widget).

Have a look: https://levelup.gitconnected.com/aem-conditionally-show-or-hide-a-field-based-on-a-checkbox-widget-o...

View solution in original post

3 Replies

Avatar

Level 1

As far as OOTB functionality goes your best option is to leverage granite/ui/components/coral/foundation/form/select and the cq-dialog-dropdown-showhide functionality. Step by step description in the js: /libs/cq/gui/components/authoring/dialog/dropdownshowhide/clientlibs/dropdownshowhide/js/dropdownshowhide.js. But I'm guessing you're not really interested in a select when you're only working with two values.

 

As for existing solutions, I'd perhaps turn towards ACS: https://adobe-consulting-services.github.io/acs-aem-commons/features/ui-widgets/show-hide-widgets/in... and failing that I'd look at the implementation of the OOTB one, and tailor it to your needs: /libs/cq/gui/components/authoring/dialog/dropdownshowhide/clientlibs/dropdownshowhide/js/dropdownshowhide.js

 

Hope any of this was useful.

Good luck!

Avatar

Correct answer by
Level 10

Hello, 

Your question inspired me to write a tutorial on how to show/hide or enable/disable fields based on a checkbox (or any other widget).

Have a look: https://levelup.gitconnected.com/aem-conditionally-show-or-hide-a-field-based-on-a-checkbox-widget-o...