When a Visualforce page is loaded, the fields accessible to the page are based on the fields referenced in the Visualforce markup. But we can use StandardController.addFields(List
method, which adds a reference to each field specified in fieldNames
so that the controller can explicitly access those fields as well.
public with sharing class AccountControllerExt { public Account acc {get; set;} public AccountControllerExt(ApexPages.StandardController controller) { List<String> accFieldList = new List<String>(); //Passing a list of field names to the standard controller controller.addFields(new List<String>{'Id', 'Name', 'AccountNumber', 'Website', 'Phone','Type', 'Industry'}); //Standard controller to retrieve the field data of the record acc = (Account)controller.getRecord(); } }