[SalesForce] How to compare custom label value in IF condition on VF page

I have a requirement to compare a variable with a custom label to show or hide section on VF page. Eg:

<apex:inputText value="{!myVariable1}" 
                 rendered="{!IF(myVariable2 == $Label.labelValue , true, false)}" />

This gives me error. I think i am using incorrect syntax or something.

Best Answer

Why would you need that formula IF? You can just do <apex:inputText value="{!myVariable1}" rendered="{!myVariable2 == $Label.labelValue}"/>

I just tested this in my developer org, and it works.

Just remember that you probably have to set up myVariable2 for this to work. If you don't, then its value will default to null, and your input will never be displayed in the page.