+ Start a Discussion
SamCousinsSamCousins 

Cannot bind fields using InputField [Fieldsets issue]

Hi all,

I'm using an apex repeat to build a modal using a fieldset.
The following works fine:
<apex:repeat value="{!currentFieldSet}" var="C"> 
    <apex:outputLabel >{!C.Label}</apex:outputLabel> 
    <apex:inputText html-placeholder="{!currentCase[C.fieldPath]}"></apex:inputText> 
</apex:repeat>


I see the field values as placeholder text in my fields.
However, due to the fieldset containing a lookup field, I would like to bind the values to input fields like so:
 
<apex:repeat value="{!currentFieldSet}" var="C"> 
    <apex:outputLabel >{!C.Label}</apex:outputLabel> 
    <apex:inputField styleClass="form-control" value="{!currentCase[C.fieldPath]}"/> 
</apex:repeat>

However, this gives the following error:
Variable is not visible: [ITSSCnC].currentCase which is [Controller].PropertyName

currentCase is a property defined as so:
public static Case currentCase {get;set;} {currentCase = new Case();}


However I do not think this is the issue, due to the first piece of code working. Does anybody have any insight into what is going on?

Additional Info:
This is how I'm populating currentCase (which is working):
currentCase = [SELECT Subject, Status, Priority, Contact.Name FROM Case WHERE Id =: caseId LIMIT 1];
This is how I'm populating the fieldset:
 
public static List<Schema.FieldSetMember> readFieldSet() { 
    Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe(); 
    Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get('Case'); 
    Schema.DescribeSObjectResult DescribeSObjectResultObj = 
    SObjectTypeObj.getDescribe(); Schema.FieldSet fieldSetObj =              DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName); 
    return fieldSetObj.getFields(); 
}

 
James LoghryJames Loghry
I see a few items that could be an issue here:
1) Input fields (if I recall correctly) use __c for lookups instead of __r, so if the field set is looking at __r instead, then that could be problematic.
2) Also, your Case variable is static, try removing the static keyword, and reorganizing your code a bit
3) To continue with the 2nd point, it's unclear to me, but it looks like you might be instanciating a new Case instance every time the get current case is called.  If that's the case, then move this to the constructor, as it won't play nice with the apex:inputField tag.