How to hide/show fields based on checkbox in AEM 6.5? | Community
Skip to main content
vigiaemnewbie
Level 2
April 2, 2020
Solved

How to hide/show fields based on checkbox in AEM 6.5?

  • April 2, 2020
  • 3 replies
  • 16531 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Theo_Pendle

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-or-anything-else-6b23b2515810

3 replies

April 2, 2020

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/index.html 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!

Adobe Employee
April 3, 2020
Theo_Pendle
Theo_PendleAccepted solution
Level 8
April 4, 2020

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-or-anything-else-6b23b2515810