A Visualforce page managed by a standard controller can provide the edit capability for a record and its parent. However, when the standard controller Save method is invoked, the object graph is not traversed and only the record being managed by the controller is saved.
In this recipe we will create a Visualforce page to allow a user to edit fields from a contact and its parent account. Saving the record will also apply any changes made to the parent account record.
This recipe makes use of an extension controller, so this will need to be created before the Visualforce page.
First, create the custom controller by navigating to the Apex Classes setup page by clicking on Your Name | Setup | Develop | Apex Classes.
Click on the New button.
Paste the contents of the
ContactAndAccountEditExt.cls
Apex class from the code download into the Apex Class area.Click on the Save button.
Next, create the Visualforce page by navigating to the Visualforce...