Tuesday, February 26, 2013

How To Display Inline Help Text of a SObject field in Visual Force Page



Most of the time when we override Visualforce page, clients/Users many time demand for same Standard page layout inline Help Text bubbles.

apex:inputField and apex:outputField shows their help Text bubble when nested within a pageBlockSection component automatically.

However, there are scenario when helpText Bubble is not displayed at VF page

scenario
----------
1- If we use "Label" attribute of "apex:outputField" , then helpText bubble is not displayed
2- If we set "showHeader=false"  of <aapex:Page>, in that case also helpText bubbles is not displayed

We can access the help text within an expression by using the respective $ObjectType global as such:

    $ObjectType.Account.Fields.myField__c.inlineHelpText

So I came up with my own idea to display help text at VF page with above two scenarios

<div id="mainContent">
    Sample helpText Example
    <span class="Custom ToolTip text">
            <img src="/s.gif" alt="Help" class="helpIcon" title="$ObjectType.Account.Fields.myField__c.inlineHelpText"/>
     </span>
</div>

By Providing "$ObjectType.Account.Fields.myField__c.inlineHelpText" in TITLE attribute of <img> tag..the helpText will be displayed as ToolTip Text