VisualForce page for new custom object
It's quite simple :)
<apex:inputField value="{!Order__c.Account__c}"/>
But maybe better will be to modify it a bit. Change the definition of order
variable in apex to this:
public Order__c order {get;set;}
I'm not sure why you marked it as private (= can't be changed from Visualforce) and final (used rather in places where you don't want to change something at all).
And then in Visualforce you can refer to it like that:
<apex:inputField value="{!order.Account__c}"/>
Liora Milbaum
Updated on July 15, 2022Comments
-
Liora Milbaum almost 2 years
I am a newbie in this field. First time trying to code a VisualForce page.
I have created a custom object named 'Order'. Added one custom field named 'Account' which is referencing to an account object. I would like to override the default New button with my own VF page.
This is my controller code:
public class orderExtension { private final Order__c order; public orderExtension (ApexPages.StandardController stdController) { order = (Order__c) stdController.getRecord(); } }
This is my VF page code:
<apex:page standardController="Order__c" extensions="orderExtension"> <apex:sectionHeader title="Order Edit" subtitle="New Order"/> <apex:form > <apex:pageBlock title="Order Edit" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save and Add Products" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Order Information" columns="2"> <apex:inputField label="Account" value="????"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Could you please assist me with the inputField? Code samples will be appreciated.
Thanks, Liora