Since release 3.19.0, ACS AEM Commons provides the functionality to show/hide dialog fields and tabs using dropdown selection or checkbox selection or the combination of both. Moreover, a required field validator is also available which applies validation only when the field is visible.
How to use
- As the first step, add the ClientLibs category acs-commons.widgets.showhidedialogfields as your project ClientLibs dependency.
- Add the empty property acs-cq-dialog-dropdown-checkbox-showhide to the dropdown/select or checkbox element
- Add the data attribute acs-cq-dialog-dropdown-checkbox-showhide-target to the dropdown/select or checkbox element, The value should be the selector, usually a specific class name, to find all possible target elements that can be shown/hidden.
- Add the target class to each target component that can be shown/hidden
- Add the class hide to each target component to make them initially hidden
- Add the attribute acs-dropdownshowhidetargetvalue to the target component, the value should equal the value of the select option that will unhide this element. Multiple values can be provided separated with spaces.
- Add the attribute acs-checkboxshowhidetargetvalue to the target component, the value should equal to:
- true, if the field is to be displayed when Checkbox is selected.
- false, if the field is to be displayed when Checkbox is unselected.
- Add both acs-dropdownshowhidetargetvalue and acs-checkboxshowhidetargetvalue attribute to each target component, which should be unhidden based on combination of dropdown and checkbox value.
- The acs-dropdownshowhidetargetvalue and/or acs-checkboxshowhidetargetvalue attribute can be added to dialog tab items to show and hide them.
- (optional) add css class acs-commons-field-required-allow-hidden to provided required field validation, which turns off when the field is hidden
Example
A test component package is provided under the following link which demonstrates the functionality. It can be used on We Retail pages.
Hi,
ReplyDeleteIm trying this one but it's not working in my system, could you please provide aem package which will include client Lib also.
Thanks.
Hi Harshad,
ReplyDeleteAdd "extraClientlibs =acs-commons.widgets.showhidedialogfields" property to your Component dialog box to load the client library.
I hope it helps.
Thanks
I have tried installing the package which is given in the Drive Link... And, It is now working... I've added this also "extraClientlibs =acs-commons.widgets.showhidedialogfields". But still I am able to see all the fields at once and they're not getting hidden on selection. Is there any other files or Files we have to change? Please help...
ReplyDeleteThanks...
hi, did you resolve the issue,
Deletei am trying on that it is not working.