[SalesForce] Help Text not appearing when using apex:outputField with a custom label

I am trying to add a custom label to an apex:outputField tag but when I do the help text disappears. How do I change the label but keep the help text?

The VF snippet below displays the same field three different ways. The first two uses a custom label and the third is the normal apex:outputField which will use the label from the SObject field. The output is shown below the code.

    <apex:pageBlockSection title="Balances" columns="1">

        <apex:pageBlockSectionItem >
            <apex:outputLabel value="My Label"/>
            <apex:outputField value="{!sob.Balance__c}"/>
        </apex:pageBlockSectionItem>

        <apex:outputField value="{!sob.Balance__c}" label="My Label"/>

        <apex:outputField value="{!sob.Balance__c}"/> 

    </apex:pageBlockSection>

Here is the output. The help text only appears on the third field.

HelpText

Best Answer

The solution is easy. Just use the helpText attribute of the apex:pageBlockSectionItem and put the help info from the field in it:

<apex:pageBlockSectionItem helpText="{!$ObjectType.Account.fields.Street__c.InlineHelpText}">
    <apex:outputLabel value="My Label"/>
    <apex:outputField value="{!a.Street__c}"/>
</apex:pageBlockSectionItem>
Related Topic