Output selected values from a checkboxgroup field

Hi, I have a content type which has a checkbox group field in it.

The user can select multiple values (check boxes) with this field.

I am now building a page template for this content type which needs to pull the selected values from this checkbox group field and output them on the page, I can’t however work out how to access the values of the selected items (check boxes).

The checkbox group field is called “loc_category” and by messing around with this I’ve got it outputting a random character “x” for each selected checkbox (node) using the code below…

#foreach($node in $sys.item.getProperty(“rx:loc_category”).getValues())
x
#end

I can’t however work out how to pull the values from these nodes (The value ID of the selected checkbox, or the label)

I’ve searched and can’t find any examples of this in practice so any help would be appreciated, thanks!

The getValues() method returns an array of Value objects.

Something like:


$allValues = $sys.item.getProperty("rx:loc_category").getValues(); 
#foreach($thisValue in $allValues)
   $thisValue.String 
#end

Will produce the list of “codes”. You can also look up the code inside the loop if you want the labels.

Thank you. We are using segments checkbox tree and this post helped me get the codes to print out. Can you please tell me how can I look up the checkbox label in jexl?