Skip to main content
Level 5
Jan 25, 2016 10:35 PM UTC
Solved

How to get value from selected optionsTextField

I have a dialog with xtype=selection field, the dropdown has the text field with the value: test1, test2 and test3; value field has the value as 1, 2, 3. When I open the dialog, I will see the test1, test2 and test3 in the dropdown list. If a user select test2, for example, the number 2 is stored as a property in CQ. I can use properties.get("fieldname") to get value 2. 

The question is how to get field text as I see in the drop down. In this case, the value should be test2.

 

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
edubey
edubeyAccepted solution
Level 10
Jan 26, 2016 3:19 AM UTC

Hi BigT168,

AEM does not provide a way to achieve this,

However whats stopping you to keep both text ( I mean label) and the value same?

5 replies

smacdonald2008
Level 10
Jan 25, 2016 10:54 PM UTC

Are you using Touch UI or Classic UI? 

Translate
BigT168Author
Level 5
Jan 25, 2016 10:58 PM UTC

CQ5.5, 

Translate
Kunal_Gaba_
New Member
Jan 25, 2016 11:40 PM UTC

The default OOTB selection field does not store the label of the dropdown along with the value so I do no think you can get the label when you retrieve the value of the field from node.

However, you can add the mapping of the label and value in the i18n data dictionary and use the dictionary to render the labels in your component scripts. If you really want the labels from the node properties then you will have to create a custom xtype which will store both label and value on the node. 

[1] http://www.wemblog.com/2011/12/how-to-use-multi-language-translation.html

Translate
edubey
edubeyAccepted solution
Level 10
Jan 26, 2016 3:19 AM UTC

Hi BigT168,

AEM does not provide a way to achieve this,

However whats stopping you to keep both text ( I mean label) and the value same?

Translate
BigT168Author
Level 5
Jan 26, 2016 4:00 PM UTC

Thank you, Kunal23 and Edubey. 

Translate