Submitting a Visualforce form without populating a required field causes an error message to be returned to the user. When the user has triggered the submission by clicking on a button, a message of this nature will not come as a surprise. If the submission is automatically triggered, for example, to retrieve fields once a lookup is populated, the sudden and unexpected appearance of an error message is a poor user experience.
In this recipe we will create a Visualforce page to create an opportunity with a number of required fields. When the user selects the account to associate the opportunity with, the form will be submitted, and related fields from the account record populated regardless of whether the required fields have been populated.
This recipe makes use of a controller extension, so this will need to be created before the Visualforce page.