0

My custom object is student__c. The form I've built looks the following:

<apex:page standardController="Student__c">
<apex:form>
    <apex:pageBlock title="Vnos novega študenta">
        <apex:pageBlockSection columns="1">
            <apex:inputField value="{! Contact.FirstName }"/>
            <apex:inputField value="{! Contact.LastName }"/>
            <apex:inputField value="{! Contact.Email }"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons>
            <apex:commandButton action="{! save}" value="Shrani" />
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>

I have created a custom object with several fields, e.g. Address__c, Birth_date__c, etc.

How can I now post to this object, add new entries, to the custom object?

3

Welcome to SFSE!

It looks like your standard controller is pointed to the Student__c Object, but all of your bindings are to the Contact object, like this

<apex:inputField value="{! Contact.FirstName }"/>

Instead, bind to your student object, like this

<apex:inputField value="{! Student__c.FirstName }"/>

Add as many fields as you need.

Then, the save method you already have on the page will correctly save new records (or update existing, if you opened the VF page from an existing record) in your Student__c object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.