0

I am using fieldsets to display fields in a VF page. Is there a way to display the help text icon next to the label if there is a help text associated with the field and display the text on hover?

Update I am not using pageblocks as we are using slds. Though the code below doesnt exactly use slds but the logic would be similar except for html and classes different.

<apex:repeat value="{!AppFields}" var="f"> 

               <div class="form-group">

                     <!--  <td class="tdStyleFirst">  -->
                      <div class="control-label col-xs-3">
                         <apex:outputlabel styleclass="control-label " value="{!f.Label}"  /><apex:outputLabel value="*" style="color:red;font-weight:bold" rendered="{!OR(f.required, f.dbrequired)}" />
                     </div>                
                     <div class="control-label col-xs-9">

                          <apex:inputField value="{!apps[f.fieldPath]}" required="{!OR(f.required, f.dbrequired)}"  styleClass="form-control" />
                      </div>                         
                </div>        

          </apex:repeat> 

Thanks

0

2 Answers 2

1

You can simply use Html css to achieve this

here is our css

div.tooltip {
     width: 20px;
     float: right;
     display:inline;
}

div.tooltip span {
     display: none;
     font-weight:normal;
     text-align:left;
     padding: 3px 5px;
     margin-left: 8px;
    width: 250px;
}

div.tooltip:hover span {
display: inline;
position: absolute;
border: 1px solid #cccccc;
background: #FFC;
color: #000000;
z-index:10000;
}

now use your css in html code

<div class="helpOrb tooltip" style="position:relative;left:10px">
   <span>
       help text
   </span>
 </div>
0

At first, this seems a duplicate of How to add field help text in visualforce page

But, as you are using fieldsets. Let me add on how to achieve this using fieldsets.

You can do dynamic binding to show helptext and it's icon. See below example.

<apex:page standardController="MyObject__c">
    <apex:pageBlock >
        <apex:pageBlockSection columns="1" title="Automatic">
            <apex:repeat value="{!$ObjectType.MyObject__c.FieldSets.MyFieldSet}" var="member">
                <apex:outputField value="{!MyObject__c[member]}"/>
            </apex:repeat>
        </apex:pageBlockSection>
        <apex:pageBlockSection columns="1" title="Dynamic Binding">
            <apex:repeat value="{!$ObjectType.MyObject__c.FieldSets.MyFieldSet}" var="member">
                <apex:pageBlockSectionItem helpText="{!$ObjectType.Object__c.fields[member].inlineHelpText}">
                    <apex:outputLabel value="{!member.label}"/>
                    <apex:outputText value="{!MyObject__c[member]}"/>
                </apex:pageBlockSectionItem>
            </apex:repeat>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Here in the pageblocksection Automatic, you will get the helptext automatically as we are using outputField, same is applicable for inputField

In in the pageblocksection Dynamic Binding, you will see the helptext is set by us in pageBlockSectionItem as we are using outputText, same is applicable for inputText. Here the helptext from the object is fetched and displayed.

Hope this helps!

3
  • Sorry. I should have been little more clear on my question. I am not using pageblocks as it's using slds.
    – Prady
    Commented Apr 26, 2018 at 9:14
  • Can you paste your code in the question? Commented Apr 26, 2018 at 9:30
  • Updated the question with code
    – Prady
    Commented Apr 26, 2018 at 15:49

Not the answer you're looking for? Browse other questions tagged .