Search code examples
orbeon

Orbeon forms - get dropdown's label


example form: https://demo.orbeon.com/demo/fr/orbeon/builder/edit/f44c7d78e5c9e76ec00df2bf9bdcf63d3b708c76

I'm trying to get dropdown label value. I was able to get label value (by attribute @label) from dynamic dropdown when 'Service performs search' is set to Yes. But when 'Service performs search' is set to No or when I use static dropdown I was unable to get label value. enter image description here

Is it possible to get label value in other cases?


Solution

  • If you had a regular dropdown, you would use the xxf:itemset() function. That function returns XML or JSON that represents all the choices, with the selected choice marked as such. For more on this, see the doc on xxf:itemset(). So you could do something like:

    xxf:itemset(
        'my-dropdown', 
        'xml', 
        true()
    )/itemset/choices/item[@selected = 'true']/value
    

    But currently, xxf:itemset() doesn't work with XBL controls, and the Dropdowns with search are XBL controls. This is covered by request for enhancement #768.