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]}" />

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]}" />

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.

  • You need to extract the info from Name of school and put it in an iterable
    – Eric
    Aug 30, 2016 at 2:20
  • 1
    You can use inputText Aug 30, 2016 at 2:27
  • @Eric I tried doing that by putting it in a String and got the same result. Does it need to be a SF object, not just a string? Aug 30, 2016 at 2:28
  • 1
    You are missing the {!} as well right?
    – Eric
    Aug 30, 2016 at 3:41

2 Answers 2


You can use <apex:inputText required="{!reqd}" value="{!form[localFieldName]}" /> as <apex:inputField/> is applicable to SObjects.

For more info, refer apex:inputText


As you told form is a sObject here, then you can bind sObject fields dynamically. check this link : http://forceschool.blogspot.in/2011/06/dynamic-binding-when-object-name-is.html

  • I am not having trouble with that one - form[] syntax is working for me. It is the form[localFieldName] syntax which is not working .. Aug 30, 2016 at 2:28
  • form is a map here? Aug 30, 2016 at 2:35
  • form is a custom sObject, not a map. Aug 30, 2016 at 2:45
  • I think you have to check this link forceschool.blogspot.in/2011/06/…. Aug 30, 2016 at 2:51

You must log in to answer this question.

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