I have some VF code that is working - basically, I have a custom object form
and I am updating the fields via components like this:
<apex:repeat value="{!jewishEducationalHistoryFields}" var="fieldAPI" >
<apex:variable value="{!requiredMap[fieldAPI.Field_API_Name__c]}" var="reqd">
<apex:outputLabel value="{!labelMap[fieldAPI.Field_API_Name__c]}" html-class="field-label"/>
<apex:inputField required="{!reqd}" html-class="{!fieldAPI.Field_CSS__c}" value="{!form[fieldAPI.Field_API_Name__c]}" />
</apex:variable>
Note the syntax in the inputField
tag. Note that the variable fieldAPI.Field_API_Name__c
is a String.
This is working.
If I modify the syntax slightly, and instead pass in a String variable directly, like below, then I get the classic error message that inputfield can only be used with sObjects, and it complains specifically about this binding.
<apex:variable value="Name_of_School__c" var="localFieldName">
<apex:variable value="{!requiredMap[localFieldName]}" var="reqd">
<apex:outputLabel value="{!labelMap[localFieldName]}" html-class="field-label" />
<apex:inputField required="{!reqd}" value="{!form[localFieldName]}" />
</apex:variable>
</apex:variable>
Any help would be greatly appreciated, thanks!
Note: I have also tried storing the literal value Name_of_School__c
in a String variable on the controller and passing that in, and I get the same error.