We needed to extend a default functionality of standard salesforce page and buttons on this page. That is we needed to display some custom buttons and fields on the standard page and perform our own logic for these. The Object for which we needed to modify functionality was Event. SInce the Event is a type of activity in salesforce and not much customizations were possible on this object, so we have overridden the standard new and save buttons on this page.
Solution:
For the overriding standard button to display custom VF page:
1. Go to setup and then select the object for which buttons need to be overridden.
2. Click Edit next to the button you want to override.
3. Since events and tasks don’t have their own tabs, we can only override their standard buttons and links.
4. Pick Visualforce Page as an override type.
5. Select the Visualforce page you want to run when users click the button or tab.
For the VF page that is to be displayed on clicking this overridden button:
1. We need to set standard controller same as of the object that we are overriding the buttons. e.g if we are overriding a button on Event object then in the VF page we need to use:
<apex:page standardController="Event">
2. For adding custom functionality to this page we can use extension to the standard controller and include it in our page as:
<apex:page standardController="Event" extensions="EventExtension">
3. For the page content, we can use display standard fields and buttons along with any custom field or buttons.
4. For displaying standard fields and saving their values while the page is saved we can use ObjectApiName.StandardFeldName notation to access the field on page. e.g if we wan to display standard Event fields on our custom VF page we can do it as follows:
<apex:inputField value="{!Event.Ownerid}">/>
<apex:inputField value="{!Event.Location}"/>
and so on for any of the field that we want to be added in the display.