display custom property in form option field | Community
Skip to main content
Level 2
December 11, 2021
Solved

display custom property in form option field

  • December 11, 2021
  • 1 reply
  • 1094 views

Hello everyone

I have a this node structure in my project :

 

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

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

 

And the form options display the property text of each country

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Shubham_borole

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

1 reply

Shubham_borole
Community Advisor
Community Advisor
December 12, 2021

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

 

odabioAuthor
Level 2
December 13, 2021

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

Shubham_borole
Community Advisor
Shubham_boroleCommunity AdvisorAccepted solution
Community Advisor
December 16, 2021

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