I'm an Apex and Visualforce beginner with not much overall programming experience to boot.
I've been tasked with updating a VF page that needs to display a series of checkboxes defined in a field set. When the user clicks 'Save' on the page, the values of the selected checkboxes should be populated on a newly created record but that isn't what's happening.
I followed the Salesforce Working with Field Sets docs and was able to get the checkboxes to display on the page, but the selected values aren't being saved to the new record.
The VF page is using a standard controller for the custom object c4g_Case_Note__c
with a custom controller in an extension. Here's the page def from the VF page:
<apex:page standardController="c4g_Case_Note__c" extensions="CaseNoteController" lightningStylesheets="true" sidebar="false" tabstyle="Case">
Here's the section in the page that references the field set, which is called Housing Topics:
<!--Housing Topics section-->
<apex:pageBlockSection title="Housing Topics" rendered="{!renderHousingTopics}">
<apex:repeat value="{!$ObjectType.c4g_Case_Note__c.FieldSets.Housing_Topics}" var="f">
<apex:inputField value="{!c4g_Case_Note__c[f]}" />
</apex:repeat>
</apex:pageBlockSection>
I assumed that using a standard controller and an <inputField>
element meant that I wouldn't need to update the controller to save the fields. I should also note that the block above is inside a set of <form>
tags.
Did I so something wrong in setting up the section, or do I have to somehow track the selected fields in the controller? Thanks.
CaseNoteController
extension that exposes the current record? (assume it is calledtheRec
, then try<apex:inputField value="{!theRec[f]}" />
)caseNote
. I updated the value for the input field to{!caseNote[f]}
and the checkbox values now save as expected. Thanks!