Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Show-Hide in the multifield based on dropdown selection

Avatar

Level 2

Hi Guys

I have two fields

1. Dropdown with two options (1. type1, 2. type2)

2. Multifield with 4 items (item1, item2, item3, item4 ==> four items all are text fields)

 

case1: Now I want to show item2, item3 and item4 fields  when a content author select dropdown option as type1

 1. Dropdown(type1)

      2. Multifield

                   -item2

                   -item3

                   -item4

case2: I want to show item1 and item4 fields when a content author select dropdown option as type2

     1. Dropdown(type2)

      2. Multifield

                   -item1

                   -item4

 

Can someone please help me how to achieve this one
Thanks in advance 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
6 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Level 2

Thanks @arunpatidar  for the reply.

I have checked with above link. Above link is working when the dropdown is part of multifield. But here the dropdown field is separate from multifield. 

Avatar

Community Advisor

In this case you need to write your own logic



Arun Patidar

Avatar

Community Advisor

Multifield fields only appear when click on add and if drop-down is out of multi-field so i believe it won’t work for hide-show with granite:data but just check if that’s not happening so you can follow this https://www.linkedin.com/pulse/aem-hideshow-drop-down-select-options-more-than-one-values-vikraman

but if it’s not working then simplest would be to maintain 2 separate multifield and as explained in above document to show his the multifield.

another option would be to write your own JavaScript and do the validation based on both drop-down value and click of multifield to show the field accordingly. I can’t find any document for this but will surely work 

Avatar

Community Advisor

Hi @mahesh_tesla ,
What is your exact use case. Here can be two scenario. 
1. Hide/Show multifield items on dropdown item change. say, multifield has multiple items open however you want multifile item show/hide on dropdown.

2.  On multifield item add. say you have specific value on dropdown and based on selected dropdown value, multifield items will be visible. 
Which event trigger multifield item hide/show