XF 2.3 Unable to conditionally check selected option in style property template

unutKan

Member
Hi,
I'm developing a custom style property using a <xf:radiorow> inside a style_property_template template. The selected option is saved correctly and shown properly in the style property page, even after refresh.

HTML:
<xf:radiorow name="{$formBaseKey}[selected_function]">
    <xf:option value="design1" selected="{$property.property_value.selected_function} == 'design1'">
        Design 1
    </xf:option>
    <xf:option value="design2" selected="{$property.property_value.selected_function} == 'design2'">
        Design 2
    </xf:option>
</xf:radiorow>

Screenshot 2025-05-12 at 14-47-16.webp


However, I can't use the selected value inside an &lt;xf:if&gt; condition. For example, this doesn't work:

HTML:
<xf:if is="{$property.property_value.selected_function} == 'design1'">
    <p>This should show if design1 is selected.</p>
</xf:if>

OR

HTML:
<xf:if is="{$property.property_value.propertyname} == 'design1'">
    <p>This should show if design1 is selected.</p>
</xf:if>

Even though design1 is selected and shown on the page, the condition never evaluates as true.
Am I using the wrong variable, or is there a special way to access selected values from style properties in style_property_template templates?


Thanks in advance!
 
You can try dumping the variable with {{ dump($property) }} to inspect its values which can help figure out how to get what you're after.
 
Back
Top Bottom