0

VF Page

<apex:page standardController="Applications__c" lightningStylesheets="true">
<apex:sectionHeader title="Application For Employment"/>
<apex:form >
    <apex:pageBlock >
      <apex:pageBlockSection columns="1" showHeader="true" title="Application For Employment">
        <apex:inputField value="{!Applications__c.Full_Name__c}"/>
        <apex:inputField value="{!Applications__c.Job_Posting__c}"/>
        <apex:inputField value="{!Applications__c.Company__c}"/>
        <apex:inputField value="{!Applications__c.Positions__c}"/>
        <apex:inputField value="{!Applications__c.Phone__c}"/>
      </apex:pageBlockSection> 

      <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Insert" action="{!save}" />
      </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>  

Controller:

public class Applications_c { 
public Job_Posting__c Job_Posting{get; set;}
public Applications__c createapplication{get; set;}  

public void createapplication() {
    createapplication = new Applications__c();
}
public PageReference saveApplication() {
    insert createapplication;
    return null;
}

}

This is my code to be able to insert a new application. It doesnt create a new record, not getting any errors.

1

1 Answer 1

-1

VF page :

<apex:page controller="Applications" lightningStylesheets="true">
<apex:sectionHeader title="Application For Employment"/>
<apex:form >
<apex:pageBlock >
  <apex:pageBlockSection columns="1" showHeader="true" title="Application For Employment">
    <apex:inputField value="{!createapplication.Full_Name__c}"/>
    <apex:inputField value="{!createapplication.Job_Posting__c}"/>
    <apex:inputField value="{!createapplication.Company__c}"/>
    <apex:inputField value="{!createapplication.Positions__c}"/>
    <apex:inputField value="{!createapplication.Phone__c}"/>
  </apex:pageBlockSection> 

  <apex:pageBlockButtons location="bottom">
    <apex:commandButton value="Insert" action="{!saveApplication}" />
  </apex:pageBlockButtons>
</apex:pageBlock>

Controller :

public class Applications { 
public Job_Posting__c Job_Posting{get; set;}
public Applications__c createapplication{get; set;}  

public Applications() {
    createapplication = new Applications__c();
}
public PageReference saveApplication() {
    insert createapplication;
    return null;
}

Changes needed :

  • you have to use controller in VF page for custom controller.
  • created one constructor and initialized the createapplication object.
  • used createapplication object in VF page in input field.
  • on button action was save. but you have written saveApplication method to save so replaced action from "save" with "saveApplication".
2
  • Hi @patelkiran3090, I downvoted your answer because you just dumped a few code lines without any information. Please consider editing your answer and provide explanations about the suggested solution so OP can learn for next time.
    – Json
    Jul 11, 2019 at 8:00
  • i did not dumped. i changed his code only and changed some things which was wrong. which anyone can understand by comparing code. added description now. is this okay? or you need some more information? Jul 11, 2019 at 9:23

You must log in to answer this question.

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