Skip to main content
added 202 characters in body
Source Link
Matt M
  • 1.5k
  • 6
  • 28
  • 56

I am a bit stuck. I have tweaked many VF pages that have custom controllers but I haven't really ever had to make one from scratch. I am stuck on the following item. If I just want to insert a new record into a custom object, no lookup or passing values around, what is the most basic syntax for a controller to create a custom record?

**EDIT: This will be shown as a sidebar VF page. **

Here is my VF page: ( I did start out using the standard controller for object.)

<apex:page Controller="Admin_Tracking_Controller" showHeader="false" sidebar="false">
    <style>
        //removed for post
    </style>
    
    <apex:form style="background-color:#D8DDE7;height:350px" >
        <div class="h1">
            Admin Time Tracking
        </div>
        <div class="b1">       
            <apex:outputText >Activity:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Activity__c}"/>
            <br/><apex:outputText >Account:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Account__c}"/>
            <br/><apex:outputText >The Hub:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.The_Hub__c}"/>
            <br/><apex:outputText >Carrier:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Carrier__c}"/>
            <br/><apex:outputText >Time Utilized:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Time_Utilized__c}"/>
            <br/><apex:outputText >Notes:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Tracking_Notes__c}" style="resize:none;height:50px;"/>
        </div> 
        
        <div class="b2" align="center" draggable="false" > 
            <apex:commandButton value="Save Time Entry" action="{!save}" />
        </div> 
        
    </apex:form>
    
</apex:page>

My best guess at controller:

public class Admin_Tracking_Controller {

  public Admin_Tracking_Controller() {
    
  }

}

Here is what this looks like with the standard controller: enter image description here

I am a bit stuck. I have tweaked many VF pages that have custom controllers but I haven't really ever had to make one from scratch. I am stuck on the following item. If I just want to insert a new record into a custom object, no lookup or passing values around, what is the most basic syntax for a controller to create a custom record?

Here is my VF page: ( I did start out using the standard controller for object.)

<apex:page Controller="Admin_Tracking_Controller" showHeader="false" sidebar="false">
    <style>
        //removed for post
    </style>
    
    <apex:form style="background-color:#D8DDE7;height:350px" >
        <div class="h1">
            Admin Time Tracking
        </div>
        <div class="b1">       
            <apex:outputText >Activity:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Activity__c}"/>
            <br/><apex:outputText >Account:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Account__c}"/>
            <br/><apex:outputText >The Hub:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.The_Hub__c}"/>
            <br/><apex:outputText >Carrier:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Carrier__c}"/>
            <br/><apex:outputText >Time Utilized:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Time_Utilized__c}"/>
            <br/><apex:outputText >Notes:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Tracking_Notes__c}" style="resize:none;height:50px;"/>
        </div> 
        
        <div class="b2" align="center" draggable="false" > 
            <apex:commandButton value="Save Time Entry" action="{!save}" />
        </div> 
        
    </apex:form>
    
</apex:page>

My best guess at controller:

public class Admin_Tracking_Controller {

  public Admin_Tracking_Controller() {
    
  }

}

I am a bit stuck. I have tweaked many VF pages that have custom controllers but I haven't really ever had to make one from scratch. I am stuck on the following item. If I just want to insert a new record into a custom object, no lookup or passing values around, what is the most basic syntax for a controller to create a custom record?

**EDIT: This will be shown as a sidebar VF page. **

Here is my VF page: ( I did start out using the standard controller for object.)

<apex:page Controller="Admin_Tracking_Controller" showHeader="false" sidebar="false">
    <style>
        //removed for post
    </style>
    
    <apex:form style="background-color:#D8DDE7;height:350px" >
        <div class="h1">
            Admin Time Tracking
        </div>
        <div class="b1">       
            <apex:outputText >Activity:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Activity__c}"/>
            <br/><apex:outputText >Account:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Account__c}"/>
            <br/><apex:outputText >The Hub:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.The_Hub__c}"/>
            <br/><apex:outputText >Carrier:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Carrier__c}"/>
            <br/><apex:outputText >Time Utilized:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Time_Utilized__c}"/>
            <br/><apex:outputText >Notes:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Tracking_Notes__c}" style="resize:none;height:50px;"/>
        </div> 
        
        <div class="b2" align="center" draggable="false" > 
            <apex:commandButton value="Save Time Entry" action="{!save}" />
        </div> 
        
    </apex:form>
    
</apex:page>

My best guess at controller:

public class Admin_Tracking_Controller {

  public Admin_Tracking_Controller() {
    
  }

}

Here is what this looks like with the standard controller: enter image description here

Source Link
Matt M
  • 1.5k
  • 6
  • 28
  • 56

Custom Controller for Custom Object Insert

I am a bit stuck. I have tweaked many VF pages that have custom controllers but I haven't really ever had to make one from scratch. I am stuck on the following item. If I just want to insert a new record into a custom object, no lookup or passing values around, what is the most basic syntax for a controller to create a custom record?

Here is my VF page: ( I did start out using the standard controller for object.)

<apex:page Controller="Admin_Tracking_Controller" showHeader="false" sidebar="false">
    <style>
        //removed for post
    </style>
    
    <apex:form style="background-color:#D8DDE7;height:350px" >
        <div class="h1">
            Admin Time Tracking
        </div>
        <div class="b1">       
            <apex:outputText >Activity:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Activity__c}"/>
            <br/><apex:outputText >Account:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Account__c}"/>
            <br/><apex:outputText >The Hub:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.The_Hub__c}"/>
            <br/><apex:outputText >Carrier:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Carrier__c}"/>
            <br/><apex:outputText >Time Utilized:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Time_Utilized__c}"/>
            <br/><apex:outputText >Notes:</apex:outputText>
            <br/><apex:inputField value="{!Admin_Tracking__c.Tracking_Notes__c}" style="resize:none;height:50px;"/>
        </div> 
        
        <div class="b2" align="center" draggable="false" > 
            <apex:commandButton value="Save Time Entry" action="{!save}" />
        </div> 
        
    </apex:form>
    
</apex:page>

My best guess at controller:

public class Admin_Tracking_Controller {

  public Admin_Tracking_Controller() {
    
  }

}