Hello everyone,
Attached is a "small"
Description:
Show and hide multiple text boxes and form fields depending on dropdown form or any other posible button selection.
If I may formulate it in Excel manners.
If "Niko" is in the drop down, only the fields intended for Niko should appear.
But if "Maria" is selected, only the fields intended for Maria should be displayed.
If "Niko & Maria" is selected, all fields should appear.
How can I do this?
A suggested solution with step-by-step instructions would be very nice
Working with Adobe Acrobat Pro 2020 (2020.005.30441)
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @NikoGR
Here I am giving the idea of how you can achieve it with a dropdown selector.
Your requirement is not supported by AEM OTB. So you need to create a clientlib and do some custom code for this. To achieve this you need to write a clientlib for the author dialog.
Step 1: Add your clientlib by "extraClientlibs" in your dialog.
Step 2: You can choose the "select" component which supports multiple values to select with "granite:data" => 'cq-dialog-dropdown-showhide-target=".target-item-show-hide"'
<type
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
granite:class="cq-dialog-dropdown-showhide"
fieldLabel="Type"
multiple="{Boolean}true"
name="./type">
<granite:data
jcr:primaryType="nt:unstructured"
cq-dialog-dropdown-showhide-target=".target-item-show-hide"/>
<items jcr:primaryType="nt:unstructured">
<option
jcr:primaryType="nt:unstructured"
text="Targeted Item"
value="targetedItem"/>
</items>
</type>
Step 3: Add "granite:data" => 'showhidetargetvalue="targetedItem"' in the targeted component and 'granite:class="hide target-item-show-hide"'
<targetedItem
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
granite:class="hide target-item-show-hide">
<granite:data
jcr:primaryType="nt:unstructured"
showhidetargetvalue="targetedItem"/>
Step 3: You can grab the selected items from this "select" component in the associated clientlib js as an array/list
let selectedItemList = $('.cq-dialog-dropdown-showhide').values;
Step 4: You can also grab all targeted item
let targetedItemClass = $(element).data("cqDialogDropdownShowhideTarget"); // targetedItem class which is provided in "granite:data" in select component
let targetedItemList = $(targetedItemClass);
Step 5: Then you can loop through the targeted item list and check if any item's "showhidetargetvalue" exist on the selected item list and filter out these items
var filteredItem = [];
targetedItemList.each((idx, targetedItem) => {
let targetedItemValue = $(targetedItem).data('showhidetargetvalue');
if(selectedItemList.includes(targetedItemValue)){
filteredElement.push($(targetedItem));
}
})
Step 6: Now you can show/hide those filtered items.
filteredElement.forEach(element => element.removeClass('hide'));
Hello @NikoGR
Here I am giving the idea of how you can achieve it with a dropdown selector.
Your requirement is not supported by AEM OTB. So you need to create a clientlib and do some custom code for this. To achieve this you need to write a clientlib for the author dialog.
Step 1: Add your clientlib by "extraClientlibs" in your dialog.
Step 2: You can choose the "select" component which supports multiple values to select with "granite:data" => 'cq-dialog-dropdown-showhide-target=".target-item-show-hide"'
<type
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
granite:class="cq-dialog-dropdown-showhide"
fieldLabel="Type"
multiple="{Boolean}true"
name="./type">
<granite:data
jcr:primaryType="nt:unstructured"
cq-dialog-dropdown-showhide-target=".target-item-show-hide"/>
<items jcr:primaryType="nt:unstructured">
<option
jcr:primaryType="nt:unstructured"
text="Targeted Item"
value="targetedItem"/>
</items>
</type>
Step 3: Add "granite:data" => 'showhidetargetvalue="targetedItem"' in the targeted component and 'granite:class="hide target-item-show-hide"'
<targetedItem
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
granite:class="hide target-item-show-hide">
<granite:data
jcr:primaryType="nt:unstructured"
showhidetargetvalue="targetedItem"/>
Step 3: You can grab the selected items from this "select" component in the associated clientlib js as an array/list
let selectedItemList = $('.cq-dialog-dropdown-showhide').values;
Step 4: You can also grab all targeted item
let targetedItemClass = $(element).data("cqDialogDropdownShowhideTarget"); // targetedItem class which is provided in "granite:data" in select component
let targetedItemList = $(targetedItemClass);
Step 5: Then you can loop through the targeted item list and check if any item's "showhidetargetvalue" exist on the selected item list and filter out these items
var filteredItem = [];
targetedItemList.each((idx, targetedItem) => {
let targetedItemValue = $(targetedItem).data('showhidetargetvalue');
if(selectedItemList.includes(targetedItemValue)){
filteredElement.push($(targetedItem));
}
})
Step 6: Now you can show/hide those filtered items.
filteredElement.forEach(element => element.removeClass('hide'));
Thank you very much this is one of the best step by step descriptions
I have seen in this forum so far!
Before I have any additional questions that I would certainly like to ask later if I could
Will try it out later this week and give feedback.
thx again.
Sure, and most welcome.
Views
Replies
Total Likes
Every beginning always has these strange questions... so do I
Are we talking that I can do this with Adobe 2020?
So is this step by step description for Adobe 2020?
If yes, how do I accomplish steps 1 & 2?
what about "Add your clientlib by "extraClientlibs" in your dialog." wint? where is this in adobe 2020?
I know that I'm annoying with basic things, but at the same time I try to understand everything.
Thank you for your patience and understanding in advance.
Views
Replies
Total Likes
Hello @NikoGR
for this custom plugin, you may be made a clientlib for author in your component
For every AEM Component, we have a structure
- exampleComponent
- _cq_dialog
- .content.xml
- clientlib
- main.js
- js.txt
- .content.xml
- clientlib-author
- authorClientlib.js
- js.txt
- .content.xml
- exampleComponent.html
- .content.xml
here in clientlib-author's xml file we have the category of this clientlib
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
categories="[your.author.clientlib.category]"/>
component dialog xml looks like
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Example Component"
sling:resourceType="cq/gui/components/authoring/dialog"
extraClientlibs="[your.author.clientlib.category]">
<content jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
</items>
</content>
</jcr:root>
we can add the category of the author-clientlib in the component with extraClientlibs in this way
Views
Replies
Total Likes
It's not about an XML file, it's about a PDF form that I want to create in Adobe 2020.
Better said, combine 3 separate forms into one (which has already been done)
and at the same time call up the respective form with a selection/dropdown field and hide the others.
Thank you for your patience and time.
Views
Replies
Total Likes
Views
Likes
Replies