Boolean Radio Group - Freemarker

  • I am using Hippo 11.
  • I have added a Boolean Radio Group to a document type.
  • The Radio Group has two options.

For simplicity, lets say the Radio Group has the following:
Path: selection_booleanradiogroup
trueLabel: “This is true”
falseLabel: “This is false”

I would like to have some Freemarker that does:
“if trueLable is selected, do this, else if falseLabel is selected, do this”

This page does not show how we can interact with it in the Freemarker (which would be really helpful if there was a snippets page that covered all your components:

Hope you can help :slight_smile:

Perhaps the Apache FreeMarker manual would help, such as:

Regards,

Woonsan

Thanks for getting back Woonsan. I have managed to achieve what I want looking at various stackoverflow answers and combining ideas.

For anybody else having difficulty here is what I ended up with:

<#assign isTrue=true>
    <#assign radioButton=document.selection_booleanradiogroup>

    <#if radioButton??>
        <#if radioButton?is_boolean>
            <#assign isTrue=radioButton>
            <#assign falseLabelSelected='False'>
            <#assign trueLabelSelected='True'>

             ${isTrue?then(falseLabelSelected, trueLabelSelected)}

        </#if>
    </#if>