Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

display custom property in form option field

Avatar

Level 3

Hello everyone

I have a this node structure in my project :

odabio_4-1639239856367.png

 

Which contains all the countries, and each node country(like Afghanistan) contains the following properties:

odabio_5-1639239856372.png

And in my page I have a form option field which points to my list countries

odabio_6-1639239856376.png

 

And the form options display the property text of each country

odabio_7-1639239856378.png

What I would like to do is that I would like to create another form where I can display the “phone_text” property instead of the “text”, Is there any way to do it or I will have to create another list ?

 

Thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

ok Thanks for displaying that. However for reading from same source node, please try to follow my previous suggestion..

I am not aware of something or some way that would make phone_text/phone/value as selectable by the datasource property unless we try to read it by backend, hence thought of servlet approach

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @odabio 
How are you obtaining the dropdown values for country names in your form?

 

Following can be tried. There are examples of obtaining the options by pointing the 'datasource' node of the component to the desired servlet path which in turn returns the final desired dropdown options with key and value

 

 

                             <datasource
                                        jcr:primaryType="nt:unstructured"
                                        sling:resourceType="/apps/project/functiondropdowns"
                                        dropdownSelector="countries"/>

/apps/project/functiondropdown will call the servlet. 

You can try similar approach by invoking the servlet and getting the dropdown values as country names or phone text/values based on the selection

 

 

See https://redquark.org/aem/day-17-granite-datasources/ for example. Call the servlet and return the desired text/values in json as per selection

 

Avatar

Level 3

This is how I'm obtaining my list (just config the source to list and in the list I point ot the list)

list.png

Avatar

Correct answer by
Community Advisor

ok Thanks for displaying that. However for reading from same source node, please try to follow my previous suggestion..

I am not aware of something or some way that would make phone_text/phone/value as selectable by the datasource property unless we try to read it by backend, hence thought of servlet approach