Newer Version Available
LoadFormData Class
Namespace
Example
Use methods in the LoadFormData class to set available and selected values in different form components:
1List<System.SelectOption> picklistOptions = new List<System.SelectOption>();
2picklistOptions.add(new System.SelectOption('optIn', 'Opt In'));
3picklistOptions.add(new System.SelectOption('optOut', 'Opt Out'));
4
5// Set the available options for the picklist
6loadFormData.setOptions('myPicklist', picklistOptions);
7// Add an option to the existing options for the picklist
8loadFormData.addOption('myPicklist', 'optOutAll', 'Opt Out All');
9// Select the 'optIn' option in the picklist
10loadFormData.setSelectedOption('myPicklist', 'optIn');
11
12
13List<System.SelectOption> checkboxOptions = new List<System.SelectOption>();
14checkboxOptions.add(new System.SelectOption('yes', 'Yes'));
15checkboxOptions.add(new System.SelectOption('no', 'No'));
16
17
18// Set available options for the checkbox group
19loadFormData.setOptions('myCheckbox', checkboxOptions);
20// Select the 'yes' option in the checkbox group
21loadFormData.addSelectedOption('myCheckbox', 'yes');
22// Also select the 'no' option in the checkbox group
23loadFormData.addSelectedOption('myCheckbox', 'no');
24// Another way to select both the 'yes' and 'no' options in the checkbox group
25loadFormData.setSelectedOptions('myCheckbox', new List<String>{'yes', 'no'});
26
27
28// Fill the value in the text input
29loadFormData.setTextValue('myTextInput', 'admin@salesforce.com');
30// Set the hint text for the text input
31loadFormData.setTextHint('myTextInput', 'Email Address');
32
33
34// Set the label for the button
35loadFormData.setButtonLabel('myButton', 'Save Preferences');LoadFormData Methods
The following are methods for LoadFormData.
addOption(fieldId, value, label)
addOption(fieldId, option)
Add a defined, selectable option for a checkbox, picklist, or radio
button field in a preference form.
Signature
public void addOption(String fieldId, System.SelectOption option)
Parameters
- fieldId
- Type: String
- Identifies a field in the preference form.
- option
- Type: System.SelectOption
- The option selected on a field in the preference form.
Return Value
Type: void
addSelectedOption(fieldId, option)
setOptions(fieldId, options)
Signature
public void setOptions(String fieldId, List<System.SelectOption> options)
Parameters
- fieldId
- Type: String
- Identifies a field in the preference form.
- options
- Type: List<System.SelectOption>
- The selectable options for a field in the preference form.
Return Value
Type: void
setSelectedOption(fieldId, optionValue)
setSelectedOptions(fieldId, options)
For an existing checkbox field on a preference form that has defined
values, set the values entered in the options field as the selected options. This requires the
field on the form to have defined options with a set value.
Signature
public void setSelectedOptions(String fieldId, List<String> options)
Parameters
Return Value
Type: void