function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
3 Creeks3 Creeks 

"html-data-" pass through being ignored for some field types

I am using a html-data- attribute to get the field name when looping through a fieldset:
<apex:repeat value="{!$ObjectType.My_Object__c.FieldSets.Header}" var="f">
   <apex:outputField value="{!showFieldSet[f]}" html-data-FieldName="{!f}"/>
</apex:repeat>
Which gives me the following HTML for most fields:
<span data-fieldname="MyField__c">Something Important</span>
But in other cases, the data-fieldname seems to be just ignored and is not there.  The ones that are ignored, as far as I can tell, seemed to be fields that are either of type currency or percentage...so fields that are auto formatted by visualforce when displayed.   Has anyone else come across this and know of a fix or work around?

Thanks



 
Best Answer chosen by 3 Creeks
Alain CabonAlain Cabon
Hi,

I have fully reproduced your problem.
The work around could be a trivial embedded <span> but you could need an extra <span class="fiield"> for your JS code on the client side. 
<apex:repeat value="{!$ObjectType.My_Object__c.FieldSets.Header}" var="f">
   <span class="field"><apex:outputField value="{!showFieldSet[f]}">
          <span data-fieldname="{!f}"></span> 
   </apex:outputField></span>
</apex:repeat>
Best regards
Alain

All Answers

Waqar Hussain SFWaqar Hussain SF
Have you seen the field level security of these fields. The fields should not hidden for the profile.
Alain CabonAlain Cabon
Hi,

I have fully reproduced your problem.
The work around could be a trivial embedded <span> but you could need an extra <span class="fiield"> for your JS code on the client side. 
<apex:repeat value="{!$ObjectType.My_Object__c.FieldSets.Header}" var="f">
   <span class="field"><apex:outputField value="{!showFieldSet[f]}">
          <span data-fieldname="{!f}"></span> 
   </apex:outputField></span>
</apex:repeat>
Best regards
Alain
This was selected as the best answer
3 Creeks3 Creeks
Thanks Alain.   I came up with the same workaround that you did, so I guess great minds really do think alike :)
Alain CabonAlain Cabon
I agree with what you said about the great minds for such a great work around (and thanks for pushing on the button named "Best answer")
But we have to preserve a certain sense of modesty nevertheless (even if the solution is grandiose).
Best regards
Alain