typo3fluidtypo3-11.xpowermail

HTML entities causing IF condition to fail in powermail template?


I have made a custom 'thank you' fluid template in powermail which needs to compare an option chosen in the form to an array item in a for loop.

The problem I have is that the comparison comes up false because the form value is using html entites and the array value does not.

So I tried using -> f:format.raw() and that will output the correct value on the page, but it still does not work in the if condition.

<f:for each="{items}" as="item">

    <f:if condition="{data.value -> f:format.raw()} == {item}">
    
        ...     
        
    </f:if>
    
</f:for>

The template is a cobject fluidtemplate inside powermail's Form/Create.html

The character causing the problem is " which I think data.value is reporting as &quot;


Solution

  • I found the best way around the problem is to do the opposite of f:format.raw and instead use f:format.htmlspecialchars on the values with doubleEncode="false".

    Declaring these as new variables and then comparing them, makes sure the condition gives the correct result.

    <f:variable name="selected"><f:format.htmlspecialchars doubleEncode="false">{data.value}</f:format.htmlspecialchars></f:variable>
    
    <f:for each="{items}" as="item">
    
        <f:variable name="itemValue"><f:format.htmlspecialchars doubleEncode="false">{item}</f:format.htmlspecialchars></f:variable>
    
    
        <f:if condition="{selected} == {itemValue}">
        
            ...     
            
        </f:if>
        
    </f:for>