You need to sign in to do that
Don't have an account?
M_Jones
<apex:inputField> can only be used with SObject fields.
Hi, I'm pretty new to visualforce development. I'm currently trying to create a page that will serve as an update wizard for a parent and child custom object. I'm getting the following error when trying to reference the child object (Petition__c) in the VF page.
Error: Could not resolve the entity from <apex:inputField> value binding '{!petition.Start_Date__c}'. <apex:inputField> can only be used with SObject fields.
So as it is I can get and update information from the "h2case" but not from the "petition". I'll post my vf and controller code below.
<apex:page controller="Testappnotcont"> <apex:sectionHeader title="Approval Notice Received"/> <apex:form > <apex:pageBlock title="Update Member Information"> <apex:pageblockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageblockButtons> <b>Scan approval notice into company's e-file using the following format </b> <blockquote> <FONT COLOR="#FF0000">Company Name - Approval - Last 5 digits of the approval notice</FONT> </blockquote> <apex:pageBlockSection title="H2Case Information"> <b> Update the H2Case status to "Approval Notice Recieved". </b> <apex:inputField value="{! h2case.status__c}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Petition Information"> <p> <b> Make sure that the start and end dates are correct. </b> <br/> <apex:inputField value="{! petition.Start_Date__c}"/> <br/> <apex:inputField value="{! petition.End_Date__c}"/> </p> <b> Number of workers. </b> <apex:inputField value="{! petition.Max_Workers__c}"/> <b> Date USCIS notice received. </b> <apex:inputField value="{! petition.USCIS_Received_Date__c}"/> <b> Petition Number</b> <FONT COLOR="#FF0000">(if not already updated).</FONT> <apex:inputField value="{! petition.name}"/> <b> Update Petition status to "Approved". </b> <apex:inputField value="{! petition.Petition_Status__c}"/> <b> Date the approval notice was received. </b> <apex:inputField value="{! petition.Approval_Notice_Received__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class Testappnotcont { public PageReference cancel() { return null; } public H2B_Case__c h2case {get; set;} public List<Petition__c> petition {get; set;} public Testappnotcont() { String id = ApexPages.currentPage().getParameters().get('id'); h2case = [select id, Status__c from H2B_Case__c where Id = :id][0]; petition = [select id, Start_Date__c, End_Date__c, Max_Workers__c, USCIS_Received_Date__c, Name, Petition_Status__c, Approval_Notice_Received__c from Petition__c where H2B_Case__r.Id = :h2case.Id]; } public PageReference save() { update h2case; update petition; return null; } }
You have a couple of options but the easiest thing to do would be to change your controller to this:
All Answers
Hey, It's because your petition variable is a list, so you have to use <apex:repeat> or write a getFirstPetition method that returns the first petition in the list and use that in your from.
Cheers,
Scott
Thanks Scott. What kind of get method would you need to use in order to pick out a list result?
You have a couple of options but the easiest thing to do would be to change your controller to this:
Thank you very much for the input. Everything seems to be working perfectly.