Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

display custom property in form option field

odabio
Level 3
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
Shubham_borole
Correct answer by
Community Advisor
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
Shubham_borole
Community Advisor
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

 

odabio
Level 3
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

Shubham_borole
Correct answer by
Community Advisor
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